Update of /cvsroot/xdoclet/xdoclet/modules/ejb/src/xdoclet/modules/ejb/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10324/modules/ejb/src/xdoclet/modules/ejb/entity
Modified Files: ValueObjectTagsHandler.java Log Message: fix for relations with multiple VOs (XDT-1057) Index: ValueObjectTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/ejb/src/xdoclet/modules/ejb/entity/ValueObjectTagsHandler.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** ValueObjectTagsHandler.java 4 Apr 2005 18:18:43 -0000 1.24 --- ValueObjectTagsHandler.java 4 Apr 2005 19:43:02 -0000 1.25 *************** *** 16,20 **** import xdoclet.DocletTask; import xdoclet.XDocletException; - import xdoclet.XDocletMessages; import xdoclet.modules.ejb.EjbTagsHandler; import xdoclet.modules.ejb.XDocletModulesEjbMessages; --- 16,19 ---- *************** *** 89,107 **** } ! String value = tag.getAttributeValue("match"); ! ! if (log.isDebugEnabled()) ! log.debug(method.getName() + " Match=" + value + "==" + valueObject); ! if (value == null) { ! if ("*".equals(valueObject)) ! ret = true; ! else ! ret = false; ! break; ! } ! else if (value.equals(valueObject) || value.equals("*") || "*".equals(valueObject)) { ! ret = true; break; - } } if ("*".equals(valueObject) && !excluded) { --- 88,94 ---- } ! ret = matches(tag, valueObject); ! if (ret) break; } if ("*".equals(valueObject) && !excluded) { *************** *** 245,248 **** --- 232,253 ---- } + /** + * Returns whether the passed tag matches for the passed value object + * + * @param tag the tag + * @param valueObject the value-object's match + * @return <code>true</code> if the passed tag matches + */ + private static boolean matches(XTag tag, String valueObject) + { + Log log = LogUtil.getLog(ValueObjectTagsHandler.class, "matches"); + String value = tag.getAttributeValue("match"); + + if (log.isDebugEnabled()) + log.debug("Match=" + value + "==" + valueObject); + + return (valueObject.equals(value) || "*".equals(value) || "*".equals(valueObject)); + } + public boolean isAbstractValueObject(String valueObjectName, XClass currentClass) *************** *** 501,506 **** * @return * @throws XDocletException if an error occures ! * @doc.param name="plural" optional="true" values="true, false" default="false" ! * descriptions="returns the plural if set to true" * @doc.tag type="content" */ --- 506,513 ---- * @return * @throws XDocletException if an error occures ! * @doc.param name="plural" optional="true" values="true, false" default="false" descriptions="return ! * the plural of the aggregate's name if set to true" ! * @doc.param name="decapitalize" optional="true" values="true, false" default="false" ! * descriptions="return the decapitalize aggregate's name if set to true" * @doc.tag type="content" */ *************** *** 508,518 **** { String plural = attributes.getProperty("plural"); ! if ("true".equals(plural)) { ! return currentAggregateNamePlural; ! } ! else { ! return currentAggregateName; } } --- 515,527 ---- { String plural = attributes.getProperty("plural"); + String decapitalize = attributes.getProperty("decapitalize"); + String name = "true".equals(plural) ? currentAggregateNamePlural : currentAggregateName; ! if ("true".equals(decapitalize)) { ! if (name != null && name.length() > 0) { ! name = Character.toLowerCase(name.charAt(0)) + name.substring(1); ! } } + return name; } *************** *** 825,891 **** * @todo (Aslak) use a HashSet instead of HashMap for foundFields */ - /* - * private java.util.List[] extractDocs( String class_name ) throws XDocletException - * { - * Map foundFields = new HashMap(); - * java.util.List ext_fields = new java.util.ArrayList(); - * java.util.List ext_methods = new java.util.ArrayList(); - * java.util.List ext_constructors = new java.util.ArrayList(); - * XClass cur_class = getCurrentClass(); - * ArrayList full_constructor_params = new ArrayList(); - * do - * { - * XMethod[] methods = cur_class.methods(); - * for( int j = 0; j < methods.length; j++ ) - * { - * if( PersistentTagsHandler.isPersistentField( methods[j] ) && MethodTagsHandler.isGetter( methods[j].name() ) && !foundFields.containsKey( methods[j].name() ) ) - * { - * / Store that we found this field so we don't add it twice - * foundFields.put( methods[j].name(), methods[j].name() ); - * String method_name_without_prefix = MethodTagsHandler.getMethodNameWithoutPrefixFor( methods[j] ); - * String field_name = Introspector.decapitalize( method_name_without_prefix ); - * XField field = new XFieldImpl( field_name, Modifier.PROTECTED, methods[j].returnType() ); - * ext_fields.add( field ); - * /getter method - * ext_methods.add( new XMethodImpl( methods[j].name(), Modifier.PUBLIC, new ParameterImpl[0], methods[j].returnType() ) ); - * /setter method - * ext_methods.add( new XMethodImpl( "set" + method_name_without_prefix, Modifier.PUBLIC, new ParameterImpl[]{new ParameterImpl( methods[j].returnType(), field_name )}, new TypeImpl( "void" ) ) ); - * full_constructor_params.add( new ParameterImpl( methods[j].returnType(), field_name ) ); - * } - * } - * / Add super class info - * cur_class = cur_class.superclass(); - * }while ( cur_class != null ); - * /fields: - * int modifiers = Modifier.STATIC | Modifier.FINAL; - * ext_fields.add( new XFieldImpl( "serialVersionUID", modifiers, new TypeImpl( "long" ) ) ); - * if( BmpTagsHandler.useSoftLocking( getCurrentClass() ) ) - * ext_fields.add( new XFieldImpl( "_version", Modifier.PRIVATE, new TypeImpl( "long" ) ) ); - * / TODO - * /methods: - * / if( hasDataEquals( getCurrentClass() ) ) - * / ext_methods.add( new XMethodImpl( "equals", Modifier.PUBLIC, new ParameterImpl[0], new TypeImpl( "Object", "", getDocletContext().getRoot().classNamed( "java.lang.Object" ) ) ) ); - * ext_methods.add( new XMethodImpl( "toString", Modifier.PUBLIC, new ParameterImpl[0], new TypeImpl( "int" ) ) ); - * if( BmpTagsHandler.useSoftLocking( getCurrentClass() ) ) - * { - * ext_methods.add( new XMethodImpl( "getVersion", Modifier.PUBLIC, new ParameterImpl[0], new TypeImpl( "long" ) ) ); - * ext_methods.add( new XMethodImpl( "setVersion", Modifier.PUBLIC, new ParameterImpl[]{new ParameterImpl( new TypeImpl( "long" ), "version" )}, new TypeImpl( "void" ) ) ); - * } - * /constructors: - * modifiers = Modifier.PUBLIC; - * ext_constructors.add( new XConstructorImpl( class_name, modifiers, new ParameterImpl[0] ) ); - * ext_constructors.add( new XConstructorImpl( class_name, modifiers, new ParameterImpl[]{new ParameterImpl( new TypeImpl( class_name ), "otherData" )} ) ); - * ext_constructors.add( new XConstructorImpl( class_name, modifiers, ( ParameterImpl[] ) full_constructor_params.toArray( new ParameterImpl[0] ) ) ); - * return new java.util.List[]{ext_fields, ext_methods, ext_constructors}; - * } - */ - /** - * @param template Describe what the parameter does - * @param superclasses Describe what the parameter does - * @param valueObject Describe what the parameter does - * @param type Describe what the parameter does - * @exception XDocletException - * @todo (Aslak) use a HashSet instead of HashMap for foundFields - */ private void forAllRelations(String template, boolean superclasses, String valueObject, String type) throws XDocletException { --- 834,837 ---- *************** *** 924,927 **** --- 870,878 ---- for (Iterator i = tags.iterator(); i.hasNext(); ) { XTag tag = (XTag) i.next(); + + if (!matches(tag, valueObject)) { + continue; + } + String aggreg = tag.getAttributeValue(type); String aggregName = tag.getAttributeValue(type + "-name"); *************** *** 978,982 **** currentAggregateNamePlural = null; currentRelationBeanClass = null; - break; } } --- 929,932 ---- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel