.........----------------==================----
..--==-  Mon, 12 Aug 2002 17:08:09 -0500,
..--==-  Peter Zhou (PZ) discussed:

 PZ)  I was trying to have valueobjects with different weight. In my
 PZ)  AccountBean, i want AccountLightValue contains IndividualLightValue, and
 PZ)  AccountNormalValue contains IndividualNormalValue.

Hm. I am also having trouble with what could be a similar problem.  I
think the following patch (value-object-samples-test.patch), applied
to the CVS HEAD xdoclet samples directory should compile, but doesn't.

It might have something to do with isValueObjectRelation in
xdoclet/modules/ejb/src/xdoclet/modules/ejb/entity/ValueObjectTagsHandler.java
returning true in forAllRelations, but the loop around line 730 seems
to process every tag when it should be doing a matches for exclusion.

I tried patching this to exclude the non-matches and I can see that it
gets skipped over, but it only seems to fix the problem in the getter
methods, not the setters (I've attached it anyway, maybe someone can
properly fix it).

Regards,
Andrew

Index: xdoclet/samples/src/java/test/ejb/AccountBean.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/samples/src/java/test/ejb/AccountBean.java,v
retrieving revision 1.7
diff -u -r1.7 AccountBean.java
--- xdoclet/samples/src/java/test/ejb/AccountBean.java	1 Sep 2002 11:31:57 -0000	1.7
+++ xdoclet/samples/src/java/test/ejb/AccountBean.java	19 Sep 2002 00:32:35 -0000
@@ -5,6 +5,7 @@
 import test.interfaces.AccountData;
 import test.interfaces.AccountPK;
 import test.interfaces.AccountValue;
+import test.interfaces.AccountLightValue;
 import test.interfaces.Customer;
 
 import javax.ejb.*;
@@ -54,6 +55,10 @@
  *     match="*"
  *     name="Account"
  *
+ * @ejb.value-object
+ *     match="light"
+ *     name="AccountLight"
+ *
  * @version $Revision: 1.7 $
  * @author  <a href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  */
@@ -66,6 +71,7 @@
      * @ejb.interface-method
      *
      * @ejb.persistence column-name="account_id"
+     * @ejb.value-object match="*"
      */
     public abstract Integer getId();
 
Index: xdoclet/samples/src/java/test/ejb/CustomerBean.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/samples/src/java/test/ejb/CustomerBean.java,v
retrieving revision 1.10
diff -u -r1.10 CustomerBean.java
--- xdoclet/samples/src/java/test/ejb/CustomerBean.java	1 Sep 2002 11:31:57 -0000	1.10
+++ xdoclet/samples/src/java/test/ejb/CustomerBean.java	19 Sep 2002 00:32:36 -0000
@@ -147,6 +147,14 @@
      * @ejb.transaction
      *    type="Supports"
      * @ejb.value-object
+     *    aggregate="test.interfaces.AccountLightValue"
+     *    aggregate-name="AccountLightView"
+     *    match="light"
+     *    members="test.interfaces.AccountLocal"
+     *    members-name="Account"
+     *    relation="external"
+     *    type="Collection"
+     * @ejb.value-object
      *    aggregate="test.interfaces.AccountValue"
      *    aggregate-name="AccountView"
      *    match="normal"
Index: xdoclet/modules/ejb/src/xdoclet/modules/ejb/entity/ValueObjectTagsHandler.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/modules/ejb/src/xdoclet/modules/ejb/entity/ValueObjectTagsHandler.java,v
retrieving revision 1.12
diff -u -r1.12 ValueObjectTagsHandler.java
--- xdoclet/modules/ejb/src/xdoclet/modules/ejb/entity/ValueObjectTagsHandler.java	9 Sep 2002 15:57:46 -0000	1.12
+++ xdoclet/modules/ejb/src/xdoclet/modules/ejb/entity/ValueObjectTagsHandler.java	19 Sep 2002 00:48:26 -0000
@@ -195,6 +195,41 @@
         return match;
     }
 
+    protected static boolean doesValueObjectRelationMatch(XTag tag, String valueObject)
+    {
+        Log log = LogUtil.getLog(ValueObjectTagsHandler.class, "doesValueObjectRelationMatch");
+        boolean ret = false;
+        boolean excluded = true;
+        String exclude = tag.getAttributeValue("exclude");
+        String aggreg = tag.getAttributeValue("aggregate");
+        String comp = tag.getAttributeValue("compose");
+
+        if ("true".equals(exclude) || (aggreg == null && comp == null)) {
+            excluded = true;
+            ret = false;
+        }
+
+        String value = tag.getAttributeValue("match");
+
+        if (value == null) {
+            if ("*".equals(valueObject))
+                ret = true;
+            else
+                ret = false;
+        }
+        else if (value.equals(valueObject) || value.equals("*") || "*".equals(valueObject)) {
+            ret = true;
+        }
+        else if ("*".equals(valueObject) && !excluded) {
+            ret = true;
+        }
+
+        if (log.isDebugEnabled())
+            log.debug("checking for match value " + value + " == " + valueObject + " -> " + ret);
+
+        return ret;
+    }
+
     /**
      * Gets the SubTask attribute of the ValueObjectTagsHandler class
      *
@@ -701,7 +736,7 @@
                                 log.debug("********* " + method.getName() + " ejb:value-object Tag - Type = " + type + " - Value = " + aggreg + " - Name = " + aggregName);
                             }
 
-                            if (aggreg != null) {
+                            if (aggreg != null && doesValueObjectRelationMatch(tag, valueObject)) {
                                 String currentReturnType = getCurrentMethod().getReturnType().getQualifiedName();
 
                                 if (log.isDebugEnabled()) {

Reply via email to