From: Chad B. <cwb...@us...> - 2004-10-30 23:14:00
|
User: cwbrandon Date: 04/10/30 16:13:48 Modified: andromda-hibernate/src/java/org/andromda/cartridges/hibernate/metafacades HibernateAssociationEndLogicImpl.java AssociationLinkManagerFinder.java andromda-hibernate/src/test/expected cartridge-output.zip andromda-hibernate/src/META-INF andromda-metafacades.xml andromda-hibernate/src/test/uml HibernateCartridgeTestModel.xml.zip Log: fix issue with many-to-many not being displayed correctly, add a test for the many-to-many so this won't break again Revision Changes Path 1.2 +11 -6 cartridges/andromda-hibernate/src/java/org/andromda/cartridges/hibernate/metafacades/HibernateAssociationEndLogicImpl.java Index: HibernateAssociationEndLogicImpl.java =================================================================== RCS file: /cvsroot/andromda/cartridges/andromda-hibernate/src/java/org/andromda/cartridges/hibernate/metafacades/HibernateAssociationEndLogicImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- HibernateAssociationEndLogicImpl.java 27 Oct 2004 19:44:44 -0000 1.1 +++ HibernateAssociationEndLogicImpl.java 30 Oct 2004 23:13:43 -0000 1.2 @@ -1,26 +1,31 @@ package org.andromda.cartridges.hibernate.metafacades; - /** * MetafacadeLogic implementation for * org.andromda.cartridges.hibernate.metafacades.HibernateAssociationEnd. * * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociationEnd */ -public class HibernateAssociationEndLogicImpl extends - HibernateAssociationEndLogic implements - org.andromda.cartridges.hibernate.metafacades.HibernateAssociationEnd { +public class HibernateAssociationEndLogicImpl + extends HibernateAssociationEndLogic + implements + org.andromda.cartridges.hibernate.metafacades.HibernateAssociationEnd +{ // ---------------- constructor ------------------------------- - public HibernateAssociationEndLogicImpl(Object metaObject, String context) { + public HibernateAssociationEndLogicImpl( + Object metaObject, + String context) + { super(metaObject, context); } /** * @see org.andromda.cartridges.hibernate.metafacades.HibernateAssociationEnd#isManagesRelationalLink() */ - public boolean handleIsManagesRelationalLink() { + public boolean handleIsManagesRelationalLink() + { return AssociationLinkManagerFinder.managesRelationalLink(this); } } 1.2 +23 -29 cartridges/andromda-hibernate/src/java/org/andromda/cartridges/hibernate/metafacades/AssociationLinkManagerFinder.java Index: AssociationLinkManagerFinder.java =================================================================== RCS file: /cvsroot/andromda/cartridges/andromda-hibernate/src/java/org/andromda/cartridges/hibernate/metafacades/AssociationLinkManagerFinder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- AssociationLinkManagerFinder.java 27 Oct 2004 19:44:44 -0000 1.1 +++ AssociationLinkManagerFinder.java 30 Oct 2004 23:13:46 -0000 1.2 @@ -11,7 +11,8 @@ * @since 25.10.2004 * @author <a href="http://www.mbohlen.de">Matthias Bohlen </a> */ -public abstract class AssociationLinkManagerFinder { +public abstract class AssociationLinkManagerFinder +{ /** * <p> @@ -21,27 +22,26 @@ * a row to the association table (in the case of many-to-many). The O/R * mapper (i.e. Hibernate) will do the update of the field when it saves the * manager instance to persistent store. - * * <p> * This method finds the "manager" among the classifiers which are connected * to the two association ends. For Hibernate, the manager side of the assoc * will have inverse="false", the non-manager side will have inverse="true". * </p> - * * <p> * See <a href="http://www.hibernate.org/155.html">the Hibernate docs </a> * for details. * </p> * - * @param self - * the association end that has to be checked + * @param self the association end that has to be checked * @return true or false: is this end the "manager" or not? */ - public static boolean managesRelationalLink(AssociationEndFacade self) { + public static boolean managesRelationalLink(AssociationEndFacade self) + { AssociationEndFacade otherEnd = self.getOtherEnd(); boolean bidirectional = self.isNavigable() && otherEnd.isNavigable(); - if (!bidirectional) { + if (!bidirectional) + { /* * If I am not navigable but the opposite end is, then I am the * manager! This is important because if I am not navigable, I @@ -51,38 +51,34 @@ * detect that I (or one of my fields) has changed. The O/R mapper * will update the link during *my* save() method. */ - // System.out.println("-- 1 --"); return !self.isNavigable(); } // from now on, only bidirectional associations are left to check! - - if (self.isOne2One()) { - // System.out.println("-- 2 --"); - if (self.isAggregation() || self.isComposition()) { - // System.out.println("-- 3 --"); + if (self.isOne2One()) + { + if (self.isAggregation() || self.isComposition()) + { return false; } - if (otherEnd.isAggregation() || otherEnd.isComposition()) { - // System.out.println("-- 4 --"); + if (otherEnd.isAggregation() || otherEnd.isComposition()) + { return true; } - // System.out.println("-- 5 --"); return isDefaultManager(self, otherEnd); } - if (self.isOne2Many()) { - // System.out.println("-- 6 --"); + if (self.isOne2Many()) + { return false; // the "one" side does not manage } - if (self.isMany2One()) { - // System.out.println("-- 7 --"); + if (self.isMany2One()) + { return true; // the "many" side always manages } // must be many:many now! - // System.out.println("-- 8 --"); return isDefaultManager(self, otherEnd); } @@ -92,18 +88,16 @@ * link. In this case, chooses the one with the lexically smaller f.q. name. * This is a random but reproducible choice. * - * @param self - * this end of the association - * @param otherEnd - * the other end of the association + * @param self this end of the association + * @param otherEnd the other end of the association * @return is "self" the manager? */ - private static boolean isDefaultManager(AssociationEndFacade self, - AssociationEndFacade otherEnd) { - + private static boolean isDefaultManager( + AssociationEndFacade self, + AssociationEndFacade otherEnd) + { String name1 = self.getType().getFullyQualifiedName(); String name2 = otherEnd.getType().getFullyQualifiedName(); return name1.compareTo(name2) < 0; } - } \ No newline at end of file 1.12 +69 -40 cartridges/andromda-hibernate/src/test/expected/cartridge-output.zip <<Binary file>> 1.12 +1 -0 cartridges/andromda-hibernate/src/META-INF/andromda-metafacades.xml Index: andromda-metafacades.xml =================================================================== RCS file: /cvsroot/andromda/cartridges/andromda-hibernate/src/META-INF/andromda-metafacades.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -r1.11 -r1.12 --- andromda-metafacades.xml 30 Oct 2004 21:23:44 -0000 1.11 +++ andromda-metafacades.xml 30 Oct 2004 23:13:47 -0000 1.12 @@ -5,6 +5,7 @@ metaobjectClass="org.omg.uml.foundation.core.AssociationEnd$Impl" metafacadeClass="org.andromda.cartridges.hibernate.metafacades.HibernateAssociationEndLogicImpl"> <property reference="foreignKeySuffix" default="_FK"/> + <context>org.andromda.metafacades.uml.EntityFacade</context> </metafacade> <metafacade metaobjectClass="org.omg.uml.foundation.core.Operation$Impl" 1.5 +49 -62 cartridges/andromda-hibernate/src/test/uml/HibernateCartridgeTestModel.xml.zip <<Binary file>> |