From: joelkoz (A. F. <fo...@an...> - 2005-11-11 22:02:27
|
I've noticed that a particular template can generate output conditionally based on Metafacade attributes. For example, from the Spring cartridge's META-INF/cartridge.xml file: <template path="templates/spring/hibernate/SpringHibernateDaoImpl.vsl" outputPattern="$generatedFile" outlet="daos" overwrite="true"> <modelElements variable="entity"> <modelElement> <type name="org.andromda.cartridges.spring.metafacades.SpringEntity"> <property name="daoImplementationRequired">false</property> </type> </modelElement> </modelElements> </template> Two questions: 1: If I understand correctly, the SprintEntity metaface's isDaoImplementationRequired() method MUST return "false" for this template to output its contents (i.e. for a *DaoImpl.java file to be generated). Is there any way to specify that a file should or should not be output based on a simple namespace property (i.e. if a property defined in META-INF/namespace.xml is set to a particular value in a given project's andromda.xml file)? If so, how do you do that? 2: I see that the outputPattern attribute is set using a template variable. The template sets the value of "$generatedFile", and that value is used to determine what the actual name of the file is. Does this technique work with the other attributes? In particular, I'l like my template to pick which outlet it wants to generate based on some configuration settings. Basically, I've defined a new namespace attribute named "richClient". Setting that to "true" indicates you are generating code for a rich client environment. Certain templates I want to go to a new special outlet named "client" only if rich client generation is enabled. If it is not, I want the template to generate to one of the "standard" outlets (like "services"). I'm thinking of using a template variable to name the outlet: <template path="templates/spring/SpringClientServiceLocator.vsl" outputPattern="$generatedFile" outlet="$generatedOutlet" having the template set the "$generatedOutlet" variable to either "client" or "service." You think that will work? _________________________________________________________ Reply to the post : http://galaxy.andromda.org/forum/viewtopic.php?p=6832#6832 Posting to http://forum.andromda.org/ is preferred over posting to the mailing list! |