db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata RepositoryTags.java RepositoryXmlHandler.java RepositoryElements.java
Date Sun, 30 Mar 2003 15:01:09 GMT
thma        2003/03/30 07:01:09

  Modified:    src/java/org/apache/ojb/broker/metadata RepositoryTags.java
                        RepositoryXmlHandler.java RepositoryElements.java
  Log:
  add anonymous field support
  
  Revision  Changes    Path
  1.24      +1 -4      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java
  
  Index: RepositoryTags.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- RepositoryTags.java	16 Mar 2003 12:03:01 -0000	1.23
  +++ RepositoryTags.java	30 Mar 2003 15:01:09 -0000	1.24
  @@ -133,24 +133,21 @@
           table.put("length", new Integer(LENGTH));
           table.put("precision", new Integer(PRECISION));
           table.put("scale", new Integer(SCALE));
  +        table.put(TAG_ACCESS_ANONYMOUS, new Integer(ACCESS));
   
           table.put("reference-descriptor", new Integer(REFERENCE_DESCRIPTOR));
  -        //table.put("rdfield.name", new Integer(Rdfield_name));
           table.put("class-ref", new Integer(REFERENCED_CLASS));
           table.put("foreignkey", new Integer(FOREIGN_KEY));
           table.put("auto-retrieve", new Integer(AUTO_RETRIEVE));
           table.put("auto-update", new Integer(AUTO_UPDATE));
           table.put("auto-delete", new Integer(AUTO_DELETE));
           table.put("collection-descriptor", new Integer(COLLECTION_DESCRIPTOR));
  -        //table.put("cdfield.name", new Integer(Cdfield_name));
           table.put("element-class-ref", new Integer(ITEMS_CLASS));
           table.put("inverse-foreignkey", new Integer(INVERSE_FK));
           table.put("collection-class", new Integer(COLLECTION_CLASS));
           table.put("indirection-table", new Integer(INDIRECTION_TABLE));
           table.put("fk-pointing-to-element-class", new Integer(FK_POINTING_TO_ITEMS_CLASS));
           table.put("fk-pointing-to-this-class", new Integer(FK_POINTING_TO_THIS_CLASS));
  -        //table.put("proxyCollection", new Integer(ProxyCollection));
  -        //table.put("refreshCollection", new Integer(RefreshCollection));
           table.put("jndi-datasource-name", new Integer(DATASOURCE_NAME));
           table.put("jdbc-level", new Integer(JDBC_LEVEL));
           table.put("locking", new Integer(LOCKING));
  
  
  
  1.36      +89 -12    db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
  
  Index: RepositoryXmlHandler.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- RepositoryXmlHandler.java	16 Mar 2003 12:03:01 -0000	1.35
  +++ RepositoryXmlHandler.java	30 Mar 2003 15:01:09 -0000	1.36
  @@ -55,6 +55,7 @@
    */
   
   import org.apache.ojb.broker.accesslayer.QueryCustomizer;
  +import org.apache.ojb.broker.metadata.fieldaccess.AnonymousPersistentFieldHelper;
   import org.apache.ojb.broker.util.ClassHelper;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  @@ -156,6 +157,7 @@
        */
       public void endDocument()
       {
  +    	AnonymousPersistentFieldHelper.computeInheritedPersistentFields(m_repository);
           logger.debug("endDoc");
       }
   
  @@ -339,7 +341,17 @@
   
                           String strId = atts.getValue(tags.getTagById(ID));
                           m_lastId = (strId == null ? m_lastId + 1 : Integer.parseInt(strId));
  -                        m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId);
  +                        
  +                        String strAccess = atts.getValue(tags.getTagById(ACCESS));
  +                        if (tags.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess))
  +                        {
  +                        	m_CurrentFLD = new AnonymousFieldDescriptor(m_CurrentCLD, m_lastId);

  +                        }
  +                        else
  +                        {
  +                        	m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId);
  +                        }                        
  +                        
                           m_CurrentCLD.addFieldDescriptor(m_CurrentFLD);
   
                           // prepare for custom attributes
  @@ -347,8 +359,16 @@
   
                           String fieldName = atts.getValue(tags.getTagById(FIELD_NAME));
                           if (isDebug) logger.debug("     " + tags.getTagById(FIELD_NAME)
+ ": " + fieldName);
  -                        String classname = m_CurrentCLD.getClassNameOfObject();
  -                        m_CurrentFLD.setPersistentField(ClassHelper.getClass(classname),
fieldName);
  +                        
  +                        if (tags.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess))
  +                        {
  +                        	m_CurrentFLD.setPersistentField(null, fieldName);
  +                        }
  +                        else
  +                        {
  +                        	String classname = m_CurrentCLD.getClassNameOfObject();
  +                        	m_CurrentFLD.setPersistentField(ClassHelper.getClass(classname),
fieldName);
  +                        }
   
                           String columnName = atts.getValue(tags.getTagById(COLUMN_NAME));
                           if (isDebug) logger.debug("     " + tags.getTagById(COLUMN_NAME)
+ ": " + columnName);
  @@ -429,26 +449,41 @@
   
                           break;
                       }
  +                    
                   case REFERENCE_DESCRIPTOR:
                       {
                           if (isDebug) logger.debug("    > " + tags.getTagById(REFERENCE_DESCRIPTOR));
  -                        m_CurrentORD = new ObjectReferenceDescriptor(m_CurrentCLD);
  -                        // now we add the new descriptor
  -                        m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD);
  -
  -                        // prepare for custom attributes
  -                        this.m_CurrentAttrContainer = m_CurrentORD;
  -
                           // set name attribute
                           name = atts.getValue(tags.getTagById(FIELD_NAME));
                           if (isDebug) logger.debug("     " + tags.getTagById(FIELD_NAME)
+ ": " + name);
  -                        m_CurrentORD.setPersistentField(m_CurrentCLD.getClassOfObject(),
name);
   
                           // set class-ref attribute
                           String classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS));
                           if (isDebug) logger.debug("     " + tags.getTagById(REFERENCED_CLASS)
+ ": " + classRef);
  +
  +                        ObjectReferenceDescriptor ord = null;
  +                        if (name.equals("this"))
  +                        {
  +                            checkThis(classRef);
  +                            AnonymousObjectReferenceDescriptor aord =
  +                                new AnonymousObjectReferenceDescriptor(m_CurrentCLD);
  +                            aord.setPersistentField(null, "this");
  +                            ord = aord;
  +                        }
  +                        else
  +                        {
  +                            ord = new ObjectReferenceDescriptor(m_CurrentCLD);
  +                            ord.setPersistentField(m_CurrentCLD.getClassOfObject(), name);
  +                        }
  +                        m_CurrentORD = ord;
  +
  +                        // now we add the new descriptor
  +                        m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD);
                           m_CurrentORD.setItemClass(ClassHelper.getClass(classRef));
   
  +                        // prepare for custom attributes
  +                        this.m_CurrentAttrContainer = m_CurrentORD;
  +
                           // set proxy attribute
                           String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
                           if (isDebug) logger.debug("     " + tags.getTagById(PROXY_REFERENCE)
+ ": " + proxy);
  @@ -890,4 +925,46 @@
           logger.warn("unknown isolation-level: " + isoLevel + " using RW_UNCOMMITTED as
default");
           return defIsoLevel;
       }
  +    
  +        /**
  +         * Check inheritance
  +         * @author Houar TINE
  +         */
  +        private void checkThis(String classRef)
  +        {
  +            Class actualClass = m_CurrentCLD.getClassOfObject();
  +            String superClass = actualClass.getSuperclass().getName();
  +            if (superClass.equals(classRef))
  +            {
  +                if (null != m_CurrentCLD.getBaseClass())
  +                {
  +                    throw new MetadataException(
  +                        "Multiple anonymous reference descriptor not authorized in "
  +                            + actualClass.getName());
  +                }
  +                m_CurrentCLD.setBaseClass(superClass);
  +            }
  +            else
  +            {
  +                if (superClass.equalsIgnoreCase(classRef))
  +                {
  +                    throw new MetadataException(
  +                        "Classes name are case sensitive: super class of "
  +                            + actualClass.getName()
  +                            + " is "
  +                            + superClass
  +                            + " not "
  +                            + classRef);
  +                }
  +                else
  +                {
  +                    throw new MetadataException(
  +                        "Class "
  +                            + classRef
  +                            + " is not a superclass of class "
  +                            + actualClass.getName());
  +                }
  +            }
  +
  +        }
   }
  
  
  
  1.22      +8 -1      db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java
  
  Index: RepositoryElements.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- RepositoryElements.java	16 Mar 2003 12:03:01 -0000	1.21
  +++ RepositoryElements.java	30 Mar 2003 15:01:09 -0000	1.22
  @@ -121,6 +121,7 @@
       public static final int LENGTH = 52;
       public static final int PRECISION = 53;
       public static final int SCALE = 54;
  +    public static final int ACCESS = 94;
   
       public static final int CON_MAX_ACTIVE = 55;
       public static final int CON_MAX_IDLE = 56;
  @@ -157,5 +158,11 @@
       public static final int INITIALIZATION_METHOD = 93;
   
       // maintain a next id to keep track where we are
  -    static final int _NEXT = 94;
  +    static final int _NEXT = 95;
  +    
  +    public static final String TAG_ACCESS_ANONYMOUS = "anonymous";
  +    public static final String TAG_ACCESS_READONLY  = "readonly";
  +    public static final String TAG_ACCESS_READWRITE = "readwrite";
  +
  +
   }
  
  
  

Mime
View raw message