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 2008/03/13 11:56:00 UTC

svn commit: r636707 - in /incubator/tuscany/java/sdo/sample/src/main: java/org/apache/tuscany/samples/sdo/intermediate/OppositeProperty.java resources/sports.xml resources/sports.xsd

Author: kelvingoodson
Date: Thu Mar 13 03:55:46 2008
New Revision: 636707

URL: http://svn.apache.org/viewvc?rev=636707&view=rev
Log: (empty)

Added:
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/OppositeProperty.java   (with props)
    incubator/tuscany/java/sdo/sample/src/main/resources/sports.xml   (with props)
    incubator/tuscany/java/sdo/sample/src/main/resources/sports.xsd   (with props)

Added: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/OppositeProperty.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/OppositeProperty.java?rev=636707&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/OppositeProperty.java (added)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/OppositeProperty.java Thu Mar 13 03:55:46 2008
@@ -0,0 +1,89 @@
+/**
+ *
+ *  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.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.model.ModelFactory;
+
+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;
+import commonj.sdo.helper.XMLDocument;
+
+// TODO -- make this a proper integrated sample
+public class OppositeProperty {
+
+  
+  final HelperContext hc = SDOUtil.createHelperContext();
+  static final String NSURI = "http://www.apache.org/tuscany/opposite"; 
+  
+  public static void main(String[] args) throws IOException {
+    
+    OppositeProperty inst = new OppositeProperty();
+    inst.run();
+
+  }
+
+  private void run() throws IOException {
+
+    
+    final URL url = getClass().getResource("/sports.xsd");
+    final InputStream inputStream = url.openStream();
+    hc.getXSDHelper().define(inputStream, url.toString());
+    inputStream.close();
+    
+    final URL url2 = getClass().getResource("/sports.xml");
+    final InputStream inputStream2 = url2.openStream();
+    XMLDocument unionDoc = hc.getXMLHelper().load(inputStream2, url2.toString(), null);
+    inputStream2.close();
+    
+    {
+      StringWriter w = new StringWriter();
+      hc.getXMLHelper().save(unionDoc, w, null);
+      System.out.println(w.toString());
+    }
+    
+    DataObject union = unionDoc.getRootObject();
+    DataObject p3 = union.getDataObject("member[ID=p3]");
+    DataObject t0 = union.getDataObject("team[ID=t0]");
+    t0.set("captain", p3);
+    
+    {
+      StringWriter w = new StringWriter();
+      hc.getXMLHelper().save(unionDoc, w, null);
+      System.out.println(w.toString());
+    }
+
+    
+  }
+
+}

Propchange: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/OppositeProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/OppositeProperty.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sdo/sample/src/main/resources/sports.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/resources/sports.xml?rev=636707&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/resources/sports.xml (added)
+++ incubator/tuscany/java/sdo/sample/src/main/resources/sports.xml Thu Mar 13 03:55:46 2008
@@ -0,0 +1,43 @@
+<?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.    
+ -->
+<spt:union xmlns:spt="http://www.apache.org/tuscany/sports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.apache.org/tuscany/sports sports.xsd ">
+  <member ID="p0" captainFor="t0">
+    <name>p 0</name>
+  </member>
+  <member ID="p1" captainFor="t1">
+    <name>p 1</name>
+  </member>
+  <member ID="p2">
+    <name>p 2</name>
+  </member>
+  <member ID="p3">
+    <name>p 3</name>
+  </member>
+  <team ID="t0" captain="p0">
+    <name>t 0</name>
+    <player>p0</player>
+    <player>p3</player>
+  </team>
+  <team ID="t1" captain="p1">
+    <name>t 1</name>
+    <player>p1</player>
+    <player>p2</player>
+  </team>
+</spt:union>

Propchange: incubator/tuscany/java/sdo/sample/src/main/resources/sports.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sdo/sample/src/main/resources/sports.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sdo/sample/src/main/resources/sports.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/tuscany/java/sdo/sample/src/main/resources/sports.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/resources/sports.xsd?rev=636707&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/resources/sports.xsd (added)
+++ incubator/tuscany/java/sdo/sample/src/main/resources/sports.xsd Thu Mar 13 03:55:46 2008
@@ -0,0 +1,54 @@
+<?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:sdoJava="commonj.sdo/java"
+            xmlns:sdoXML="commonj.sdo/xml"
+            xmlns:spt="http://www.apache.org/tuscany/sports"
+            targetNamespace="http://www.apache.org/tuscany/sports">
+  
+  <xsd:element name="union" type="spt:SportingUnion"/>
+    
+  <xsd:complexType name="SportingUnion">
+    <xsd:sequence>
+      <xsd:element name="member" type="spt:Player" maxOccurs="unbounded" />
+      <xsd:element name="team" type="spt:Team" maxOccurs="unbounded" />
+    </xsd:sequence>
+  </xsd:complexType>
+  
+  <xsd:complexType name="Player">
+    <xsd:sequence>
+      <xsd:element name="name" type="xsd:string"/>  
+    </xsd:sequence>
+    <xsd:attribute name="ID" type="xsd:ID"/>
+    <xsd:attribute name="captainFor" type="xsd:IDREF" sdoXML:propertyType="spt:Team"/>
+  </xsd:complexType>
+  
+  <xsd:complexType name="Team">
+    <xsd:sequence>
+      <xsd:element name="name" type="xsd:string"/>
+      <xsd:element name="player" type="xsd:IDREF" maxOccurs="unbounded"/>
+    </xsd:sequence>
+    <xsd:attribute name="ID" type="xsd:ID"/>
+    <xsd:attribute name="captain" type="xsd:IDREF" sdoXML:oppositeProperty="captainFor" sdoXML:propertyType="spt:Player" />
+  
+  </xsd:complexType>
+
+
+</xsd:schema>

Propchange: incubator/tuscany/java/sdo/sample/src/main/resources/sports.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sdo/sample/src/main/resources/sports.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sdo/sample/src/main/resources/sports.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org