User: pazu Date: 02/04/23 06:49:19 Modified: core/src/xdoclet/ejb/tags/vendor JBossRelationTagsHandler.java Log: If the user tags the relation with @jboss:relation-mapping style="relation-table" xDoclet will generate a <relation-table-mapping/> element no matter the relation is 1-1, 1-n or n-n. Revision Changes Path 1.8 +269 -211 xdoclet/core/src/xdoclet/ejb/tags/vendor/JBossRelationTagsHandler.java Index: JBossRelationTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ejb/tags/vendor/JBossRelationTagsHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -r1.7 -r1.8 --- JBossRelationTagsHandler.java 4 Apr 2002 01:03:09 -0000 1.7 +++ JBossRelationTagsHandler.java 23 Apr 2002 13:49:18 -0000 1.8 @@ -13,9 +13,10 @@ /** * @author <a href="mailto:[EMAIL PROTECTED]">David Budworth</a> * @created Feb 4, 2002 - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ -public class JBossRelationTagsHandler extends RelationTagsHandler { +public class JBossRelationTagsHandler extends RelationTagsHandler +{ /** * @todo-javadoc Describe the field */ @@ -25,7 +26,6 @@ */ private String currentFKCol = null; - /** * Describe what the method does * @@ -35,13 +35,14 @@ * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - public void ifNotLeftHasFK(String template) throws XDocletException { - if (!leftHasFK()) { + public void ifNotLeftHasFK( String template ) throws XDocletException + { + if( !leftHasFK() ) + { generate(template); } } - /** * Describe what the method does * @@ -51,13 +52,14 @@ * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - public void ifNotRightHasFK(String template) throws XDocletException { - if (!rightHasFK()) { + public void ifNotRightHasFK( String template ) throws XDocletException + { + if( !rightHasFK() ) + { generate(template); } } - /** * Describe what the method does * @@ -67,13 +69,14 @@ * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - public void ifLeftHasFK(String template) throws XDocletException { - if (leftHasFK()) { + public void ifLeftHasFK( String template ) throws XDocletException + { + if( leftHasFK() ) + { generate(template); } } - /** * Describe what the method does * @@ -83,13 +86,14 @@ * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - public void ifRightHasFK(String template) throws XDocletException { - if (rightHasFK()) { + public void ifRightHasFK( String template ) throws XDocletException + { + if( rightHasFK() ) + { generate(template); } } - /** * Describe what the method does * @@ -99,11 +103,11 @@ * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - public void forAllLeftForeignKeys(String template) throws XDocletException { + public void forAllLeftForeignKeys( String template ) throws XDocletException + { forAllForeignKeys(template, true); } - /** * Describe what the method does * @@ -113,11 +117,11 @@ * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - public void forAllRightForeignKeys(String template) throws XDocletException { + public void forAllRightForeignKeys( String template ) throws XDocletException + { forAllForeignKeys(template, false); } - /** * Describe what the method does * @@ -125,11 +129,11 @@ * @todo-javadoc Write javadocs for method * @todo-javadoc Write javadocs for return value */ - public String relatedPKField() { + public String relatedPKField() + { return currentFKRelField; } - /** * Describe what the method does * @@ -137,11 +141,11 @@ * @todo-javadoc Write javadocs for method * @todo-javadoc Write javadocs for return value */ - public String fkColumn() { + public String fkColumn() + { return currentFKCol; } - /** * Describe what the method does * @@ -151,13 +155,14 @@ * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - public void ifLeftHasFKConstraint(String template) throws XDocletException { - if (leftHasFKConstraint()) { + public void ifLeftHasFKConstraint( String template ) throws XDocletException + { + if( leftHasFKConstraint() ) + { generate(template); } } - /** * Describe what the method does * @@ -167,13 +172,14 @@ * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - public void ifRightHasFKConstraint(String template) throws XDocletException { - if (rightHasFKConstraint()) { + public void ifRightHasFKConstraint( String template ) throws XDocletException + { + if( rightHasFKConstraint() ) + { generate(template); } } - /** * Describe what the method does * @@ -183,7 +189,8 @@ * @todo-javadoc Write javadocs for return value * @todo-javadoc Write javadocs for exception */ - public String leftFKConstraint() throws XDocletException { + public String leftFKConstraint() throws XDocletException + { return getTagValue( currentRelation.getLeftMethod().doc(), "jboss:relation", @@ -195,7 +202,6 @@ ); } - /** * Describe what the method does * @@ -205,8 +211,10 @@ * @todo-javadoc Write javadocs for return value * @todo-javadoc Write javadocs for exception */ - public String rightFKConstraint() throws XDocletException { - if (currentRelation.isBidirectional()) { + public String rightFKConstraint() throws XDocletException + { + if( currentRelation.isBidirectional() ) + { return getTagValue( currentRelation.getRightMethod().doc(), "jboss:relation", @@ -217,7 +225,8 @@ false ); } - else { + else + { return getTagValue( currentRelation.getLeftMethod().doc(), "jboss:target-relation", @@ -230,6 +239,40 @@ } } + public void ifIsRelationTableMapping( String template ) throws XDocletException + { + if( isRelationTableMapping() ) + generate( template ); + } + + public void ifNotIsRelationTableMapping( String template ) throws XDocletException + { + if( !isRelationTableMapping() ) + generate( template ); + } + + /** + * Checks if the current relation should use a relation table mapping. This can + * occurs if the current relation is many-to-many or the programmer has + * explicitly set + * + * @return true if relation-table-mapping should be used + * @exception XDocletException + * @jboss:relation-mapping style="relation-table" + */ + private boolean isRelationTableMapping() throws XDocletException + { + if( currentRelation.isMany2Many() ) + return true; + if( currentRelation.getLeftMethod() != null ) + if( "relation-table".equals( currentRelation.getLeftMethod().doc().tagAttributeValue( "jboss:relation-mapping", "style" ) ) ) + return true; + if( currentRelation.getRightMethod() != null ) + if( "relation-table".equals( currentRelation.getRightMethod().doc().tagAttributeValue( "jboss:relation-mapping", "style" ) ) ) + return true; + + return false; + } /** * Describe what the method does @@ -240,8 +283,10 @@ * @todo-javadoc Write javadocs for return value * @todo-javadoc Write javadocs for exception */ - private boolean leftHasFKConstraint() throws XDocletException { - if (currentRelation.getLeftMethod() == null) { + private boolean leftHasFKConstraint() throws XDocletException + { + if( currentRelation.getLeftMethod() == null ) + { return false; } return getTagValue( @@ -255,7 +300,6 @@ ) != null; } - /** * Describe what the method does * @@ -265,8 +309,10 @@ * @todo-javadoc Write javadocs for return value * @todo-javadoc Write javadocs for exception */ - private boolean rightHasFKConstraint() throws XDocletException { - if (currentRelation.isBidirectional()) { + private boolean rightHasFKConstraint() throws XDocletException + { + if( currentRelation.isBidirectional() ) + { return getTagValue( currentRelation.getRightMethod().doc(), "jboss:relation", @@ -277,8 +323,10 @@ false ) != null; } - else { - if (currentRelation.getLeftMethod() == null) { + else + { + if( currentRelation.getLeftMethod() == null ) + { return false; } return getTagValue( @@ -293,7 +341,6 @@ } } - /** * Describe what the method does * @@ -303,14 +350,15 @@ * @todo-javadoc Write javadocs for return value * @todo-javadoc Write javadocs for exception */ - private boolean leftHasFK() throws XDocletException { - if (currentRelation.getLeftMethod() == null) { + private boolean leftHasFK() throws XDocletException + { + if( currentRelation.getLeftMethod() == null ) + { return false; } return currentRelation.getLeftMethod().doc().hasTag("jboss:relation"); } - /** * Describe what the method does * @@ -320,19 +368,22 @@ * @todo-javadoc Write javadocs for return value * @todo-javadoc Write javadocs for exception */ - private boolean rightHasFK() throws XDocletException { - if (currentRelation.isBidirectional()) { + private boolean rightHasFK() throws XDocletException + { + if( currentRelation.isBidirectional() ) + { return currentRelation.getRightMethod().doc().hasTag("jboss:relation"); } - else { - if (currentRelation.getLeftMethod() == null) { + else + { + if( currentRelation.getLeftMethod() == null ) + { return false; } return currentRelation.getLeftMethod().doc().hasTag("jboss:target-relation"); } } - /** * Describe what the method does * @@ -344,27 +395,34 @@ * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for exception */ - private void forAllForeignKeys(String template, boolean left) throws XDocletException { + private void forAllForeignKeys( String template, boolean left ) throws XDocletException + { XTag[] fktags = null; - if (left) { + if( left ) + { fktags = currentRelation.getLeftMethod().doc().tags("jboss:relation"); } - else { - if (currentRelation.isBidirectional()) { + else + { + if( currentRelation.isBidirectional() ) + { fktags = currentRelation.getRightMethod().doc().tags("jboss:relation"); } - if (fktags == null) { + if( fktags == null ) + { fktags = currentRelation.getLeftMethod().doc().tags("jboss:target-relation"); } } //maybe we should throw here? - if (fktags == null) { + if( fktags == null ) + { return; } - for (int i = 0; i < fktags.length; i++) { + for( int i = 0; i < fktags.length; i++ ) + { currentFKRelField = fktags[i].attributeValue("related-pk-field"); currentFKCol = fktags[i].attributeValue("fk-column"); generate(template);
_______________________________________________ Xdoclet-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-devel