|
From: Vance K. <va...@us...> - 2007-02-17 14:09:08
|
User: vancek
Date: 07/02/17 06:09:09
Modified: andromda-ejb3/src/test/uml EJB3CartridgeTestModel.xml.zip
andromda-ejb3/src/test/expected cartridge-output.zip
andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades
EJB3EntityFacadeLogicImpl.java
andromda-ejb3/src/main/resources/META-INF/andromda
cartridge.xml metafacades.xml
andromda-ejb3/src/main/resources/templates/ejb3
EntityEmbeddable.vsl
andromda-ejb3/src/site/resources/howto HowToPictures.zip
HowToModel.xml.zip
andromda-ejb3/src/site changes.xml
andromda-ejb3/src/main/uml EJB3MetafacadeModel.xml.zip
andromda-ejb3/src/site/axdoc howto9.xml
Added: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades
EJB3MappedSuperclassFacadeLogicImpl.java
EJB3MappedSuperclassAttributeFacadeLogicImpl.java
Log:
add EJB3MappedSuperclassFacade and EJB3MappedSuperclassAttributeFacade metafacades. No longer need to model an Entity stereotype with a MappedSuperclass stereotype on the parent class. reflect changes in docs and override validation constraints.
Revision Changes Path
1.4 +259 -262 cartridges/andromda-ejb3/src/test/uml/EJB3CartridgeTestModel.xml.zip
<<Binary file>>
1.5 +450 -449 cartridges/andromda-ejb3/src/test/expected/cartridge-output.zip
<<Binary file>>
1.29 +47 -3 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3EntityFacadeLogicImpl.java
Index: EJB3EntityFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3EntityFacadeLogicImpl.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -w -r1.28 -r1.29
--- EJB3EntityFacadeLogicImpl.java 17 Jan 2007 00:50:55 -0000 1.28
+++ EJB3EntityFacadeLogicImpl.java 17 Feb 2007 14:09:07 -0000 1.29
@@ -17,6 +17,7 @@
import org.andromda.metafacades.uml.AttributeFacade;
import org.andromda.metafacades.uml.ClassifierFacade;
import org.andromda.metafacades.uml.DependencyFacade;
+import org.andromda.metafacades.uml.Entity;
import org.andromda.metafacades.uml.EntityAssociationEnd;
import org.andromda.metafacades.uml.EntityAttribute;
import org.andromda.metafacades.uml.EnumerationFacade;
@@ -220,9 +221,9 @@
}
// No PK dependency found - try a PK attribute
- if (super.getIdentifiers() != null && !super.getIdentifiers().isEmpty())
+ if (this.getIdentifiers(true) != null && !this.getIdentifiers(true).isEmpty())
{
- AttributeFacade attr = (AttributeFacade)super.getIdentifiers().iterator().next();
+ AttributeFacade attr = (AttributeFacade)this.getIdentifiers(true).iterator().next();
identifiers.add(attr);
return identifiers;
}
@@ -233,6 +234,49 @@
}
/**
+ * This overrides the default implementation in EntityLogicImpl.java.
+ *
+ * This provides the means to check super classes, even those modelled
+ * as mapped superclasses, as well as entities.
+ *
+ * Gets all identifiers for this entity. If 'follow' is true, and if
+ * no identifiers can be found on the entity, a search up the
+ * inheritance chain will be performed, and the identifiers from
+ * the first super class having them will be used.
+ *
+ * @param follow a flag indicating whether or not the inheritance hiearchy
+ * should be followed
+ * @return the collection of identifiers.
+ */
+ public Collection getIdentifiers(boolean follow)
+ {
+ final Collection identifiers = new ArrayList(this.getAttributes());
+ MetafacadeUtils.filterByStereotype(
+ identifiers,
+ UMLProfile.STEREOTYPE_IDENTIFIER);
+
+ if (identifiers.isEmpty() && follow)
+ {
+ if (this.getGeneralization() instanceof EJB3EntityFacade)
+ {
+ return ((EJB3EntityFacade)this.getGeneralization()).getIdentifiers(follow);
+ }
+ else if (this.getGeneralization() instanceof EJB3MappedSuperclassFacade)
+ {
+ return ((EJB3MappedSuperclassFacade)this.getGeneralization()).getIdentifiers(follow);
+ }
+ else
+ {
+ return identifiers;
+ }
+ }
+ else
+ {
+ return identifiers;
+ }
+ }
+
+ /**
* @see org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacade#isSyntheticCreateMethodAllowed()
*/
protected boolean handleIsSyntheticCreateMethodAllowed()
@@ -1074,7 +1118,7 @@
if (displayAttribute == null)
{
- if (!getIdentifiers().isEmpty())
+ if (!this.getIdentifiers().isEmpty())
{
displayAttribute = (EntityAttribute)this.getIdentifiers().iterator().next();
}
1.1 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MappedSuperclassFacadeLogicImpl.java
Index: EJB3MappedSuperclassFacadeLogicImpl.java
===================================================================
package org.andromda.cartridges.ejb3.metafacades;
/**
* MetafacadeLogic implementation for org.andromda.cartridges.ejb3.metafacades.EJB3MappedSuperclassFacade.
*
* @see org.andromda.cartridges.ejb3.metafacades.EJB3MappedSuperclassFacade
*/
public class EJB3MappedSuperclassFacadeLogicImpl
extends EJB3MappedSuperclassFacadeLogic
{
public EJB3MappedSuperclassFacadeLogicImpl (Object metaObject, String context)
{
super (metaObject, context);
}
}
1.1 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MappedSuperclassAttributeFacadeLogicImpl.java
Index: EJB3MappedSuperclassAttributeFacadeLogicImpl.java
===================================================================
package org.andromda.cartridges.ejb3.metafacades;
/**
* MetafacadeLogic implementation for org.andromda.cartridges.ejb3.metafacades.EJB3MappedSuperclassAttributeFacade.
*
* @see org.andromda.cartridges.ejb3.metafacades.EJB3MappedSuperclassAttributeFacade
*/
public class EJB3MappedSuperclassAttributeFacadeLogicImpl
extends EJB3MappedSuperclassAttributeFacadeLogic
{
public EJB3MappedSuperclassAttributeFacadeLogicImpl (Object metaObject, String context)
{
super (metaObject, context);
}
}
1.37 +0 -1 cartridges/andromda-ejb3/src/main/resources/META-INF/andromda/cartridge.xml
Index: cartridge.xml
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/META-INF/andromda/cartridge.xml,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -w -r1.36 -r1.37
--- cartridge.xml 13 Feb 2007 02:41:40 -0000 1.36
+++ cartridge.xml 17 Feb 2007 14:09:08 -0000 1.37
@@ -157,7 +157,6 @@
<modelElement variable="persistenceContexts">
<type name="org.andromda.cartridges.ejb3.metafacades.EJB3PersistenceContextFacade"/>
</modelElement>
-
</modelElements>
</template>
1.30 +15 -0 cartridges/andromda-ejb3/src/main/resources/META-INF/andromda/metafacades.xml
Index: metafacades.xml
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/META-INF/andromda/metafacades.xml,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -w -r1.29 -r1.30
--- metafacades.xml 11 Feb 2007 14:06:34 -0000 1.29
+++ metafacades.xml 17 Feb 2007 14:09:08 -0000 1.30
@@ -81,6 +81,21 @@
</mapping>
</metafacade>
+ <!-- Mapped Superclass Metafacades -->
+ <metafacade class="org.andromda.cartridges.ejb3.metafacades.EJB3MappedSuperclassFacadeLogicImpl" contextRoot="true">
+ <mapping>
+ <stereotype>MAPPED_SUPERCLASS</stereotype>
+ </mapping>
+ </metafacade>
+ <metafacade class="org.andromda.cartridges.ejb3.metafacades.EJB3MappedSuperclassAttributeFacadeLogicImpl">
+ <mapping>
+ <context>org.andromda.cartridges.ejb3.metafacades.EJB3MappedSuperclassFacade</context>
+ </mapping>
+ <property reference="entityDefaultGeneratorType"/>
+ <property reference="entityDefaultGeneratorInitialValue"/>
+ <property reference="entityDefaultGeneratorAllocationSize"/>
+ </metafacade>
+
<!-- WebService Metafacades -->
<metafacade class="org.andromda.cartridges.ejb3.metafacades.EJB3WebServiceFacadeLogicImpl" contextRoot="true">
<mapping>
1.44 +28 -3 cartridges/andromda-ejb3/src/main/resources/templates/ejb3/EntityEmbeddable.vsl
Index: EntityEmbeddable.vsl
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/templates/ejb3/EntityEmbeddable.vsl,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -w -r1.43 -r1.44
--- EntityEmbeddable.vsl 17 Jan 2007 00:50:56 -0000 1.43
+++ EntityEmbeddable.vsl 17 Feb 2007 14:09:08 -0000 1.44
@@ -826,11 +826,36 @@
#else
#**##set ($entityName = $entity.entityName)
#end
-#renderEqualsMethod($entity $entityName $entity.identifiers)
+##
+## This was changed when the EJB3MappedSuperclassFacade was introduced.
+## If normal entity, use identifier attributes
+## If mapped superclass there are 2 options
+## If an identifier has been explicity defined, then use the identifier
+## If an identifier has been dynamically created, then use normal attributes and not the identifier
+##
+#if (${entity.embeddableSuperclass})
+#**##if ($entity.dynamicIdentifiersPresent)
+#* *##set ($attributeSet = ${updatableAttributes})
+#**##else
+#* *##set ($attributeSet = ${entity.identifiers})
+#**##end
+#else
+#**##set ($attributeSet = ${entity.identifiers})
+#end
+#renderEqualsMethod($entity $entityName $attributeSet)
-#renderHashCodeMethod($entity $entity.identifiers)
+#renderHashCodeMethod($entity $attributeSet)
-#renderToStringMethod($entity $entityName $entity.attributes)
+#if (${entity.embeddableSuperclass})
+#**##if ($entity.dynamicIdentifiersPresent)
+#* *##set ($attributeSet = ${updatableAttributes})
+#**##else
+#* *##set ($attributeSet = ${entity.attributes})
+#**##end
+#else
+#**##set ($attributeSet = ${entity.attributes})
+#end
+#renderToStringMethod($entity $entityName $attributeSet)
#if (!$entity.entityImplementationRequired && !$entity.embeddableSuperclass && !$entity.requiresGeneralizationMapping)
#renderCompareToMethod($entity $entityName $entity.identifiers)
1.2 +197 -150 cartridges/andromda-ejb3/src/site/resources/howto/HowToPictures.zip
<<Binary file>>
1.2 +239 -194 cartridges/andromda-ejb3/src/site/resources/howto/HowToModel.xml.zip
<<Binary file>>
1.10 +9 -0 cartridges/andromda-ejb3/src/site/changes.xml
Index: changes.xml
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/site/changes.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- changes.xml 12 Feb 2007 02:13:16 -0000 1.9
+++ changes.xml 17 Feb 2007 14:09:08 -0000 1.10
@@ -377,6 +377,15 @@
Resource libs jms-ra.rar and jcainflow.rar are copied to src/test/resources folder of the core project
for testing of message driven test cases.
</action>
+ <action dev="vancek" type="update">
+ Added EJB3MappedSuperclassFacade and EJB3MappedSuperclassAttributeFacade metafacades extending EJB3EntityFacade
+ and EJB3EntityAttributeFacade respectively. This enables the ability to model a mapped superclass by modelling
+ only the MappedSuperclass stereotype. The existing way required the Entity stereotype as well as the
+ MappedSuperclass stereotype. This excludes a mapped superclass in the group of manageable entities, if entities
+ are modelled as Manageable as well.
+ Also added 2 constraints to the EJB3EntityFacade class. These constraints override
+ the default identifier check and generalization check constraints in the parent Entity metafacade.
+ </action>
</release>
</body>
</document>
\ No newline at end of file
1.52 +263 -226 cartridges/andromda-ejb3/src/main/uml/EJB3MetafacadeModel.xml.zip
<<Binary file>>
1.4 +26 -1 cartridges/andromda-ejb3/src/site/axdoc/howto9.xml
Index: howto9.xml
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/site/axdoc/howto9.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- howto9.xml 19 Jan 2007 14:35:42 -0000 1.3
+++ howto9.xml 17 Feb 2007 14:09:09 -0000 1.4
@@ -106,6 +106,31 @@
guidelines since there is no inheritance hierarchy for this entity. Therefore, only a
<code>Person</code> class is generated and should not be modified.
</p>
+ <p>
+ If you are going to enable manageable entities, you must ONLY enable
+ your identifiers in the subclass and not the parent mapped superclass. Furthermore, you must
+ also disable
+ the following two constraints in your <code>andromda.xml</code> by adding the following
+ <b>constraints</b> section. Rest assured that by disabling these constraints, your are not
+ vulnerable to modelling flaws, since the constraints on the <i>EJB3EntityFacade</i> will
+ enforce these constraints.
+<source language="xml"><![CDATA[
+ <repository name="netBeansMDR">
+ <models>
+ <model>
+ <uri>${model.uri}</uri>
+ <moduleSearchLocations>
+ <location patterns="**/*.xml.zip">${settings.localRepository}/org/andromda/profiles/</location>
+ </moduleSearchLocations>
+ <constraints enforceAll="true">
+ <constraint enforce="false">org::andromda::metafacades::uml::Entity::entities can only generalize other entities</constraint>
+ <constraint enforce="false">org::andromda::metafacades::uml::Entity::entity must have at least one primary key</constraint>
+ </constraints>
+ </model>
+ </models>
+ </repository>
+]]></source>
+ </p>
</subsection>
<a name="Single_Table_Strategy"/>
<subsection name="Single Table Strategy">
|