[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DB implementation - Relationships between Collection, Resource and XMLContainer
On Thu, 7 Jun 2001 15:47:49 +0200
"Per Nyfelt" <per.nyfelt@nordicwave.com> wrote:
> I got a response on the XML:DB list confirming the idea that Resources
> should be contained in Collections so I moved on using the (to me) simplest
> interpretation of that idea which is to have a Map in CollectionImpl that
> has id as their key and the Resource object as the value. For the
> XMLResourceImpl i chose to use a Node as the content for the Resource. I'm
> now able to test all use cases for DOM successfully and are moving on to
> the String based stuff now.
>
> I'm not sure if choosing Node for Resource content is right. it works but
> maybe I'm not considering all scenarios. When Lars put the skeleton code in
> CVS he seemed to have had the idea to use an XMLContainer for the content
> instead of Node.
Are you using a persistent DOM Node or how do you ensure to make a
node persistent in ozone? The reason why I used XMLContainer instead
of Node as a member of XMLResource is that XMLContainer already
implements helper methods to store/retrieve content (SAX, DOM, ...)
in a very efficient way (streaming). Without this you have to re-
implement such features because you'll come to the point where you'll
need them.
My aim was/is to preserve the current OzoneXML-API (except of the
addition of collections). Therefore I would like to see the XML:DB API
on top of ozoneXML, because the ozoneXML API is much "rawer" then
XML:DB.
On the other hand I don't want to mix the implementation of XML:DB
with the core ozone features like proxies, database objects, ...
If you will take a look at the "xml/core" module you'll find the
counterpart of XMLContainer what is the persistent XMLCollection.
> The difference would basically be:
>
> 1. Use aggregation. The Collection is stored in Ozone and it contains
> XMLResources which contains Node objects. I changed the constructor to work
> with this idea i.e.
> public XMLResourceImpl( String id, OzoneInterface database, Collection
> collection) {
>
> this.database = database;
> this.collection = collection;
> this.id = id;
>
> }
>
> 2. Use association. Both Collections and the XML as XMLContainers are
> explicitly stored in Ozone. The Collection would not have a Map but instead
> a list of id's that allows for the XML document to be found using
> objectForName(id). For this to be smooth a getName() method should be added
> to XMLContainer so that id does not have to be specified twice in the
> construction of the XMLRersourceImpl. i.e.
>
> public XMLResourceImpl( OzoneInterface database, Collection collection,
> XMLContainer container ) {
> this.database = database;
> this.container = container;
> this.collection = collection;
> this.id = container.getName();
>
> }
>
> Any ideas/suggestions?
>
> Best regards,
> Per
>
> > -----Original Message-----
> > From: ozone-dev-owner@ozone-db.org
> > [mailto:ozone-dev-owner@ozone-db.org]On Behalf Of Per Nyfelt
> > Sent: den 30 maj 2001 10:52
> > To: ozone-dev@ozone-db.org
> > Subject: XML:DB implementation - Relationships between Collection,
> > Resource and XMLContainer
> >
> >
> > I'm struggling with CollectionImpl.createResource(). What should be the
> > relationships between org.xmldb.api.base.Collection,
> > org.xmldb.api.base.Resource and org.ozoneDB.xml.util.XMLContainer? I
> > something like the following in mind but I'm not sure this is a
> > valid route:
> >
> > public Resource createResource( String id, String type ) throws
> > XMLDBException {
> > try {
> > if ( ( id == null ) || ( id.equals("") ) ) {
> > id = createId();
> > }
> > if ( type.equals(XMLResource.RESOURCE_TYPE) ) {
> > // what to do with this?
> > return new XMLResourceImpl(database,this,
> > XMLContainer.newContainer( database, id));
> > }
> > else if ( type.equals(BinaryResource.RESOURCE_TYPE) ) {
> > throw new XMLDBException( ErrorCodes.VENDOR_ERROR,
> > "BinaryResource: Not yet implemented");
> > }
> > else {
> > throw new
> > XMLDBException(ErrorCodes.UNKNOWN_RESOURCE_TYPE);
> > }
> > }
> > catch (Exception e) {
> > throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR,
> > e.toString());
> > }
> > }
> >
> > Then for CollectionImpl.storeResource() i'm not sure how the storage of a
> > Resource should be viewed. If Collection should aggregate Resources we
> > should store the resource inside the Collection but then
> > Collection needs to
> > have a list (Map) of Resources. On the other hand if we store it as a
> > separate object what denoted its relationship with a Collection?
> >
> > public void storeResource( Resource res ) throws XMLDBException {
> > try {
> > String id = res.getId();
> > if ((id == null) || (id.length() == 0)) {
> > id = createId();
> > }
> > // what to do whith this?
> > database.createObject( Resource.class.getName(),
> > OzoneInterface.Public, id);
> > }
> > catch (Exception e) {
> > throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR,
> > e.toString());
> > }
> > }
> >
> > Any suggestions?
> >
> > Best regards,
> > Per
> >
> >
>
--
______________________________________________________________________
Lars Martin mailto:lars@smb-tec.com
SMB GmbH http://www.smb-tec.com