Package commonj.sdo

Examples of commonj.sdo.DataGraph


            SDOUtil.setContainment(property, true);
            SDOUtil.setMany(property, true);
        }

        // Create the DataGraph
        DataGraph g = SDOUtil.createDataGraph();

        // Create the root object
        g.createRootObject(rootType);

        ChangeSummary summary = g.getChangeSummary();
        summary.beginLogging();

        return g.getRootObject();
    }
View Full Code Here


            }
        }
        _setDeleted(true);

        /** Order here is important - the dataGraph pointer should be cleared preorder before we enter the recursive loop to clear child DO's */
        DataGraph previousDataGraph = getDataGraph();
        // Remove back pointer to containing DataGraph
        setDataGraph(null);       

        List instancePropertiesList = getInstanceProperties();
        for (int i = 0, psize = instancePropertiesList.size(); i < psize; i++) {
View Full Code Here

         * company DataObject That is either associated with a DataGraph or independant
         */
        boolean useDataGraph = shouldUseDataGraph();

        // define these so that they will be scoped appropiately.
        DataGraph dataGraph = null;
        DataObject company = null;

        if (useDataGraph) {

            /**
             * The SDO specification says the following about creating a DataGraph A DataGraph is created by a DAS, which returns either an empty
             * DataGraph, or a DataGraph filled with DataObjects. An empty DataGraph can have a root assigned by the createRootObject() methods.
             * However, if a previous root DataObject exists then an IllegalStateException is thrown.
             *
             * In order to create a simply sample which creates a DataGraph without the use of a DAS this sample will use the
             * {@link org.apache.tuscany.sdo.util.SDOUtil} class to create a DataObject
             */

            dataGraph = SDOUtil.createDataGraph();
            company = dataGraph.createRootObject(SdoSampleConstants.COMPANY_NAMESPACE, "CompanyType");                                        
           
        } else {

            /*
             * The following creates a DataObject without a DataGraph
View Full Code Here

        List typesDefined = types.define(types2define);

        // Create an empty data graph and add a root object, an instance of customerType
        //

        DataGraph dataGraph = SDOUtil.createDataGraph();
        Type customerTypeDefined = (Type) typesDefined.get(1);
        DataObject customer1 = dataGraph.createRootObject(customerTypeDefined);

        customer1.setInt("custNum", 1);
        customer1.set("firstName", "John");
        customer1.set("lastName", "Adams");
        DataObject address = customer1.createDataObject("address");
        address.set("addrSt", "577 Airport Blvd");

        SDOUtil.registerDataGraphTypes(dataGraph, typesDefined);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SDOUtil.saveDataGraph(dataGraph, baos, null);
        //SDOUtil.saveDataGraph(dataGraph, System.out, null);

        TypeHelper deserializingTypeHelper = SDOUtil.createTypeHelper();
       
        // The following is a kludge to force deserialization of metadata into a different TypeHelper (scope)
        // TBD figure out a proper non-EMF way to do this.
        Map options = new HashMap();
        Object differentFromSerializing = ((TypeHelperImpl) deserializingTypeHelper).getExtendedMetaData();
        options.put(XMLResource.OPTION_EXTENDED_META_DATA, differentFromSerializing);

        byte[] serialized = baos.toByteArray();
        ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
        DataGraph loadedDataGraph = SDOUtil.loadDataGraph(bais, options);

        DataObject loadedRootObject = loadedDataGraph.getRootObject();
        assertNotSame(loadedRootObject.getType(), customer1.getType());

        // EqualityHelper requires same Type
        assertEquals(loadedRootObject.getInt("custNum"), customer1.getInt("custNum"));
        assertEquals(loadedRootObject.get("firstName"), customer1.get("firstName"));
View Full Code Here

           
           
            /**
             * Use utility method to obtain an actual DataGraph from the xml
             */                       
            DataGraph datagraph = SDOUtil.loadDataGraph(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_DATAGRAPH_XML), null);
            // Obtain the company DataObject from the actual DataGraph
            company = datagraph.getRootObject();
            System.out.println("Obtained actual DataGraph:");
            System.out.println(datagraph);
            System.out.println("Obtained root DataObject from DataGraph:");
            System.out.println(company);           
            System.out.println();
View Full Code Here

   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetEDataGraph(DataGraph newEDataGraph, NotificationChain msgs)
  {
    DataGraph oldEDataGraph = eDataGraph;
    eDataGraph = newEDataGraph;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, oldEDataGraph, newEDataGraph);
      if (msgs == null) msgs = notification; else msgs.add(notification);
View Full Code Here

   * <!-- end-user-doc -->
   * @generated NOT
   */
  public DataObject getRootObject()
  {
    DataGraph dataGraph = getDataGraph();
    if (dataGraph != null)
    {
      return dataGraph.getRootObject();
    }
    // TODO: handle ChangeSummary-type property
    return null;
  }
View Full Code Here

    return null;
  }
 
  public static ChangeSummary getChangeSummary(DataObject dataObject)
  {
    DataGraph dataGraph = getDataGraph(dataObject);
    if (dataGraph != null)
    {
      return dataGraph.getChangeSummary();
    }
    // TODO: handle ChangeSummary-type property
    return null;
  }
View Full Code Here

    }
  }
 
  public static Type getType(DataObject dataObject, String namespaceURI, String typeName)
  {
    DataGraph dataGraph = dataObject.getDataGraph();
    if (dataGraph != null)
    {
      return dataGraph.getType(namespaceURI, typeName);
    }
    else
    {
      //TODO think about where else to find the type
      return TypeHelper.INSTANCE.getType(namespaceURI, typeName);
View Full Code Here

      return target;
    }
   
    protected void writeDataObject(DataObject dataObject, ObjectOutput objectOutput) throws IOException
    {
      DataGraph dataGraph = dataObject.getDataGraph();
      if (dataGraph != null)
      {
        objectOutput.writeByte(0);
        objectOutput.writeUTF(DataObjectUtil.getXPath(dataObject));
        objectOutput.writeObject(dataGraph);
View Full Code Here

TOP

Related Classes of commonj.sdo.DataGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.