Update of
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-hibernate/src/main/java/org/xdoclet/plugin/hibernate
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19170/src/main/java/org/xdoclet/plugin/hibernate
Modified Files:
Class.jelly HibernateMappingPlugin.java Properties.jelly
Log Message:
Refactoring @hibernate.properties
Index: Class.jelly
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-hibernate/src/main/java/org/xdoclet/plugin/hibernate/Class.jelly,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** Class.jelly 31 May 2005 11:24:35 -0000 1.19
--- Class.jelly 15 Jun 2005 12:56:06 -0000 1.20
***************
*** 122,126 ****
<!-- process properties -->
<j:forEach var="property" items="${plugin.getClassProperties(class)}">
! <j:if
test="${property.entity.getTagByName('hibernate.properties') == null}">
<!-- If this property has 'hibernate.properties' it means
that property already outputted -->
<j:import uri="/HibernateProperties.jelly" inherit="true"/>
--- 122,126 ----
<!-- process properties -->
<j:forEach var="property" items="${plugin.getClassProperties(class)}">
! <j:if test="${plugin.getTagByNameList(property.entity,
plugin.tagListAllowedInProperties).getNamedParameter('properties-name') ==
null}">
<!-- If this property has 'hibernate.properties' it means
that property already outputted -->
<j:import uri="/HibernateProperties.jelly" inherit="true"/>
Index: HibernateMappingPlugin.java
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-hibernate/src/main/java/org/xdoclet/plugin/hibernate/HibernateMappingPlugin.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** HibernateMappingPlugin.java 1 Jun 2005 14:52:57 -0000 1.42
--- HibernateMappingPlugin.java 15 Jun 2005 12:56:06 -0000 1.43
***************
*** 104,114 ****
* Get all candidates for properties tag
*/
! public List getAlternateKeyProperties(JavaClass clazz) {
List retval = new ArrayList();
getPropertiesRecursive(clazz, null, ALLOWED_IN_PROPERTIES_TAGS,
retval);
return retval;
}
/**
* provide list of properties candidating for class id
*
--- 104,150 ----
* Get all candidates for properties tag
*/
! public List getAlternateKeyProperties(JavaClass clazz, final String
propertiesName) {
! if (propertiesName == null) {
! return null;
! }
!
List retval = new ArrayList();
getPropertiesRecursive(clazz, null, ALLOWED_IN_PROPERTIES_TAGS,
retval);
+ CollectionUtils.filter(retval,
+ new Predicate() {
+ public boolean evaluate(Object object) {
+ HibernateProperty prop = (HibernateProperty) object;
+ DocletTag tag = getTagByNameList(prop.getEntity(),
ALLOWED_IN_PROPERTIES_TAGS);
+
+ if (tag == null) {
+ return false;
+ }
+
+ return
propertiesName.equalsIgnoreCase(tag.getNamedParameter("properties-name"));
+ }
+ });
return retval;
}
/**
+ * Get at least one doclet tag from javaEntity
+ * @param entity entity which have doclet tags
+ * @param tagNames list of possible tag names
+ * @return found doclet tag or null if there is no such tag
+ */
+ public DocletTag getTagByNameList(AbstractJavaEntity entity, List
tagNames) {
+ for (int i = 0; i < tagNames.size(); i++) {
+ String tag = (String) tagNames.get(i);
+ DocletTag docletTag = entity.getTagByName(tag);
+
+ if (docletTag != null) {
+ return docletTag;
+ }
+ }
+
+ return null;
+ }
+
+ /**
* provide list of properties candidating for class id
*
***************
*** 211,214 ****
--- 247,257 ----
/**
+ * provide list of valid property tags that can be used inside
<properties> tag
+ */
+ public List getTagListAllowedInProperties() {
+ return ALLOWED_IN_PROPERTIES_TAGS;
+ }
+
+ /**
* provide list of hibernate properties for subclass. it could be getter,
as
* well as field ( for direct property access ). we stop at
hibernate.class
Index: Properties.jelly
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-hibernate/src/main/java/org/xdoclet/plugin/hibernate/Properties.jelly,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Properties.jelly 31 May 2005 11:24:36 -0000 1.2
--- Properties.jelly 15 Jun 2005 12:56:06 -0000 1.3
***************
*** 2,26 ****
<j:if test="${propertiesTag != null}">
<properties
! name="${propertiesTag.name_}"
! unique="${propertiesTag.unique}"
! insert="${propertiesTag.insert}"
! update="${propertiesTag.update}"
! optimistic-lock="${propertiesTag.optimisticLock}"
! node="${propertiesTag.node}">
!
! <j:set var="propName" value="${propertiesTag.name_}"/>
! <j:forEach var="property"
items="${plugin.getAlternateKeyProperties(class)}">
! <j:set var="propertiesTag"
value="${property.entity.getTagByName('hibernate.properties')}"/>
! <j:if test="${propertiesTag != null and propertiesTag.name_
== propName}">
! <!-- process property -->
! <j:import uri="/Property.jelly" inherit="true"/>
! <!-- process many-to-one -->
! <j:import uri="/ManyToOne.jelly" inherit="true"/>
! <!-- process component -->
! <j:import uri="/Component.jelly" inherit="true"/>
! <!-- process dynamic-component -->
! <j:import uri="/DynamicComponent.jelly" inherit="true"/>
! </j:if>
</j:forEach>
</properties>
--- 2,17 ----
<j:if test="${propertiesTag != null}">
<properties
! name="${propertiesTag.name_}"
! unique="${propertiesTag.unique}"
! insert="${propertiesTag.insert}"
! update="${propertiesTag.update}"
! optimistic-lock="${propertiesTag.optimisticLock}"
! node="${propertiesTag.node}">
! <j:forEach var="property"
items="${plugin.getAlternateKeyProperties(class, propertiesTag.name_)}">
! <j:import uri="/Property.jelly" inherit="true"/>
! <j:import uri="/ManyToOne.jelly" inherit="true"/>
! <j:import uri="/Component.jelly" inherit="true"/>
! <j:import uri="/DynamicComponent.jelly" inherit="true"/>
</j:forEach>
</properties>
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
xdoclet-plugins-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits