Please, see if this patch can help you !
It changes RepositoryXmlhandler to make collection descriptors avaible
to extents.


On Tue, 2003-06-24 at 10:17, Weaver, Scott wrote:
> I was looking at the DescriptorRepository class and I feel I could easily patch it 
> to walk the inheritance tree for "invisible" mappings via inheritance.  I will patch 
> it if this functionality desired.  
> 
> 
> *===================================*
> * Scott T Weaver                    *
> * Jakarta Jetspeed Portal Project   *
> * [EMAIL PROTECTED]                 *
> *===================================*
>   
> 
> 
> > -----Original Message-----
> > From: Leandro Rodrigo Saad Cruz [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, June 24, 2003 7:28 AM
> > To: OJB Users List
> > Subject: Re: extents and mapping inheritence
> > 
> > I have inherence working for collection descriptors. I'm planning to add
> > reference and field inherence too. When I have time :-(
> > 
> > On Mon, 2003-06-23 at 16:02, Jakob Braeuchi wrote:
> > > hi scott,
> > >
> > > ojb does not support inheritence of field- and relationship-descriptors.
> > > but there are some discussions going on regarding this feature.
> > >
> > > hth
> > > jakob
> > >
> > > Weaver, Scott wrote:
> > >
> > > >Is there anyway to have a class-descriptor inherit the mappings of a
> > previously defined class-descriptor?
> > > >
> > > >Example:
> > > >
> > > >AB is an interface.  A implements AB and B extends A.
> > > >
> > > ><class-descriptor class="AB" >
> > > >   <extent-class class-ref="A" />
> > > >   <extent-class class-ref="B" />
> > > ></class-descriptor>
> > > >
> > > >
> > > ><class-descriptor class="A" table="AB">
> > > >  <field-descriptor name="id"column="ID" jdbc-type="INTEGER"
> > > >   primarykey="true"
> > > >   autoincrement="true"
> > > >  />
> > > >  <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/>
> > > ></class-descriptor>
> > > >
> > > >The question:  How can define the class-descriptor for B without having
> > to copy the identical mappings from A?
> > > >
> > > >I tried using the "extends" attribute of class-descriptor on hunch
> > that's what it was for, however, no dice.
> > > >
> > > >There has got to be a simple way to accomplish this, however, I have
> > yet to find it.
> > > >
> > > >Using 1.0rc3.
> > > >
> > > >Thanks,
> > > >*===================================*
> > > >* Scott T Weaver                    *
> > > >* Jakarta Jetspeed Portal Project   *
> > > >* [EMAIL PROTECTED]                 *
> > > >*===================================*
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > --
> > Leandro Rodrigo Saad Cruz
> > IT - Inter Business Tecnologia e Servicos (IB)
> > http://www.ibnetwork.com.br
> > http://db.apache.org/ojb
> > http://xingu.sourceforge.net
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
-- 
Leandro Rodrigo Saad Cruz
IT - Inter Business Tecnologia e Servicos (IB)
http://www.ibnetwork.com.br
http://db.apache.org/ojb
http://xingu.sourceforge.net
Index: src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
===================================================================
RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java,v
retrieving revision 1.43
diff -u -b -B -r1.43 RepositoryXmlHandler.java
--- src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java	10 Jun 2003 20:42:09 -0000	1.43
+++ src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java	24 Jun 2003 14:27:33 -0000
@@ -59,11 +59,19 @@
 import org.apache.ojb.broker.util.ClassHelper;
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
+import org.apache.ojb.broker.util.ClassHelper;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
+//JDK
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.Map;
+import java.util.HashMap;
+
+
 /**
  * The handler catches Parsing events raised by the xml-parser
  * and builds up the DescriptorRepository that is used within the
@@ -106,6 +114,12 @@
     private RepositoryTags tags = RepositoryTags.getInstance();
 
     /**
+     * PARENT-CHILD map
+     *
+     */
+    private Map parent_child_map = new HashMap();
+
+    /**
      * returns the XmlCapable id associated with the literal.
      * OJB maintains a RepositoryTags table that provides
      * a mapping from xml-tags to XmlCapable ids.
@@ -294,7 +308,8 @@
 
                         //set initializationMethod attribute
                         String initializationMethod = atts.getValue(tags.getTagById(INITIALIZATION_METHOD));
-                        if (isDebug) logger.debug("     " + tags.getTagById(INITIALIZATION_METHOD) + ": " + initializationMethod);
+                        if (isDebug) logger.debug("     " + tags.getTagById(INITIALIZATION_METHOD) + ": " 
+                                                  + initializationMethod);
                         if (initializationMethod != null)
                         {
                             m_CurrentCLD.setInitializationMethod(initializationMethod);
@@ -312,8 +327,22 @@
 
                 case CLASS_EXTENT:
                     {
+                        /*
+                         * LEANDRO ( baserose )
+                         * If I have extents, I may be parent of other class descriptor 
+                         * related to collection and reference descriptors
+                         */
                         String classname = atts.getValue("class-ref");
-                        if (isDebug) logger.debug("     " + tags.getTagById(CLASS_EXTENT) + ": " + classname);
+
+                        if (isDebug) 
+                            logger.debug("     " + tags.getTagById(CLASS_EXTENT) + ": " + classname);
+
+                        parent_child_map.put(classname,m_CurrentCLD);
+
+                        if (isDebug) 
+                            logger.debug("** registering "+classname+" as son of "
+                                         +m_CurrentCLD.getClassOfObject());
+
                         m_CurrentCLD.addExtentClassName(classname);
                         break;
                     }
@@ -765,7 +794,31 @@
                     }
                 case FIELD_DESCRIPTOR:
                     {
-                        if (isDebug) logger.debug("    < " + tags.getTagById(FIELD_DESCRIPTOR));
+                        ClassDescriptor relative;
+                        CollectionDescriptor relativeCod;
+
+                        relative = (ClassDescriptor)parent_child_map.get(m_CurrentCLD.getClassNameOfObject());
+
+                        while(relative != null)
+                        {
+                            for(Iterator it = relative.getCollectionDescriptors().iterator() ; it.hasNext();)
+                            {
+                                relativeCod = (CollectionDescriptor)it.next();
+                                if(null == m_CurrentCLD.getCollectionDescriptorByName(relativeCod.getAttributeName()))
+                                {
+                                    logger.debug("** adding collection ["+relativeCod.getAttributeName()
+                                                 +"] indirection table ["
+                                                 + relativeCod.getIndirectionTable()
+                                                 +"] class desc ["
+                                                 + relativeCod.getClassDescriptor().getClassNameOfObject()
+                                                 +"] from relative "+relative.getClassNameOfObject());
+                                    m_CurrentCLD.addCollectionDescriptor(relativeCod);
+                                }
+                            }
+                            relative = (ClassDescriptor)parent_child_map.get(relative.getClassNameOfObject());
+                        }
+                        if (isDebug)
+                            logger.debug("    < " + tags.getTagById(FIELD_DESCRIPTOR));
                         m_CurrentFLD = null;
                         m_CurrentAttrContainer = m_CurrentCLD;
                         break;
@@ -913,23 +966,23 @@
      */
     private int getIsoLevel(String isoLevel)
     {
-        if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_UNCOMMITTED))
+        if (LITERAL_IL_READ_UNCOMMITTED.equalsIgnoreCase(isoLevel))
         {
             return IL_READ_UNCOMMITTED;
         }
-        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_COMMITTED))
+        else if (LITERAL_IL_READ_COMMITTED.equalsIgnoreCase(isoLevel))
         {
             return IL_READ_COMMITTED;
         }
-        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_REPEATABLE_READ))
+        else if (LITERAL_IL_REPEATABLE_READ.equalsIgnoreCase(isoLevel))
         {
             return IL_REPEATABLE_READ;
         }
-        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_SERIALIZABLE))
+        else if (LITERAL_IL_SERIALIZABLE.equalsIgnoreCase(isoLevel))
         {
             return IL_SERIALIZABLE;
         }
-        else if (isoLevel.equalsIgnoreCase(LITERAL_IL_OPTIMISTIC))
+        else if (LITERAL_IL_OPTIMISTIC.equalsIgnoreCase(isoLevel))
         {
             return IL_OPTIMISTIC;
         }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to