| By Kelvin Goodson, Geoffrey Winn | Article Rating: |
|
| February 26, 2007 04:15 PM EST | Reads: |
41,561 |
Containment
Something to note here is that we have
created a containment relationship between the person1 DataObject and
the referrals DataObject. SDO treats containment relationships in a
special way. In every data graph each data object apart from the root
has a link to exactly one parent data object that is its container. The
corresponding property from the parent to the child is marked as a
containment property. So the containment relationships form a strict
hierarchical structure whereby every data object in a graph is
reachable by traversing only the containment links. To enable SDO to
describe richer, more diverse graph structures, non-containment links
can also be included into the graph. These non-containment links permit
arbitrary references across the containment hierarchy.
SDO has behavior built in to preserve the containment hierarchy constraint; so, for example, if you assign a data object into a graph as the value of a containment property then any existing value at that location in the graph will be automatically displaced (the value of its parent property becomes null and the orphaned data object, along with any children it might have, becomes a separate data graph). In addition, if the data object that you're assigning to the graph is already contained in a data graph then it will be automatically removed from that containment association before being assigned to its new location.
Let's take a look at an example. Suppose that the institutions running the tests have learned from the mistakes of previous such projects in which patients already diagnosed with a condition have inadvertantly received letters intended for new referrals and this caused unnecessary distress. This was seen as sufficiently important for them to engineer their data models to ensure that referrals and patients were always disjoint sets. Listing 2 shows the XML schema used to model the test. It makes use of the schema shown earlier to model the people involved in the test.
This schema has a global element named "test," which is of type "Test," which contains three sets of people: referrals, patients, and relatives. We saw from the previous schema that a PersonSet contains a list of people so this arrangement of containment relationships ensures that if we assign a person who already exists in the set of referrals to be in the set of patients then by virtue of the preservation of containments constraint, that person is automatically removed from the referrals set by the SDO infrastructure. Let's see that in action.
DataObject test = DataFactory.INSTANCE.create("www.example.org/MedicalTest", "Test");
test.set("referrals", referrals);
At this point our entire test consists of a set of referrals with one member (we haven't yet initialized the set of patients or relatives so they take the default null value). Here's how it would serialize to XML.
<Test:test xmlns:Test="www.example.org/MedicalTest">
<referrals>
<person gender="male" id="1" name="Joe Johnson Snr">
<dob>1 January 1950</dob>
</person>
</referrals>
</Test:test>
Having visited the hospital, Joe Johnson Sr. is found to have symptoms indicating one of the conditions that the test is investigating, so he's added to the set of patients.
DataObject patients = test.createData-Object("patients");
patients.getList("person").add(person1);
As an aside, note how we created the patients DataObject in a more concise way this time. The "test" DataObject knows the type of its "patients" property and so we don't need to use DataFactory to look up the type and create an instance.
Having made this assignment of person1 to the set of patients, this is how the whole test serializes.
<Test:Test xmlns:Test="www.example.org/MedicalTest">
<referrals/>
<patients>
<person gender="male" id="1" name="Joe Johnson Snr."/>
</patients>
</Test:Test>
So as a result of this one assignment, the patient's set has one member and the referrals set has been reduced to zero.
In part two of this article, we'll examine more SDO features, including the use of open content, change summaries, and references between objects that express more than containment.
References
1 Williams, K., Daniel, B. "SOA Web Services - Data Access Service", Java Developer's Journal, August 2006, http://java.sys-con.com/read/260053.html
Published February 26, 2007 Reads 41,561
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Kelvin Goodson
Kelvin Goodson is based at IBM Hursley in the UK as part of the Open Source SOA team. He is a committer to the Apache Tuscany incubator project, and works primarily on development of the Tuscany Java implementation of SDO. He gained a Ph.D. in image analysis and artificial intelligence in 1988, and has previously worked in the areas of medical imaging, weather forecasting and messaging middleware.
More Stories By Geoffrey Winn
Geoff Winn is based at IBM Hursley in the UK, as part of the Open Source SOA team. He is a member of the SDO specification group and currently works on development of the Apache Tuscany C++ implementation of SDO. He has degrees in Mathematics and Computation, and has previously worked in the areas messaging and brokering middleware.
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- It's the Java vs. C++ Shootout Revisited!
- Cloud Computing Can Revitalize Your Career as Software Developer
- IBM Could "Reinvent" Java: Mills
- Oracle & Cloud Computing: Exclusive Q&A with SVP Richard Sarwal
- A Brief History of Cloud Computing
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- i-Technology Predictions for 2007: Where's It All Headed?








































