Hi Chad,

the first easy step is to make the Metafacade more configurable.

Just by adding the property file to the UMLProfile
(UMLProfile.properties) and change the UMLProfile.java a
litte bit (so it will read the data from the property file),
it will be very easy for everyone (including me ;-)) to
change the name of the stereotypes, taggedvalues, etc.
without having to rewrite the whole Entity*.java within
the Metafacade (like EntityFacadeLogicImpl,
EntityAttributeFacadeLogicImpl, etc.) and without
recompiling the whole AndroMDA (IMO, it is easier just
to edit the property file instead of editing the Java file
and recompiling the whole Metafacade). Besides this has
to be done everytime after updating the CVS...

It would be very nice if you can update these two files
in AndroMDA CVS. I already tested those files and they
worked smoothly.

I attach the 2 files. Just copy these two files into:
andromda-all\metafacades\uml\common\src\java\org\andromda\metafacades\uml\

And after this everyone can use their own convention
in their own cartridge ;-)

Thanks!
--
---------------------------------------------------
Blasius Lofi Dewanto
---------------------------------------------------
OpenUSS - Open University Support System
http://openuss.sourceforge.net
---------------------------------------------------
E-Mail   : [EMAIL PROTECTED]
ICQ      : 39343280
---------------------------------------------------

Chad Brandon schrieb:
 > Sounds like a good idea...I had been thinking of similar implementation.
 > I'll see if I can add something like this soon.
 >
 >
 > ----- Original Message -----
 > From: "Lofi Dewanto" <[EMAIL PROTECTED]>
 > To: "Chad Brandon" <[EMAIL PROTECTED]>
 > Cc: <[EMAIL PROTECTED]>;
 > <[EMAIL PROTECTED]>
 > Sent: Saturday, July 03, 2004 8:41 AM
 > Subject: Re: [Andromda-user] Using other naming convension for the
 > stereotypes?
 >
 >
 >
 >>Hi Chad,
 >>
 >>thanks for your reply.
 >>
 >><chad>
 >>Oh I agree...I think we need to come up with a way to
 >>easily configure stereotypes and tagged values.
 >>Ideas?
 >></chad>
 >>
 >>1. The easiest thing is to use one centralized property file
 >>like "UMLProfile.property".
 >>
 >>2. The UMLProfile.java should read all its constants from
 >>this property file, so that you can change the string values easier,
 >>without recompiling Metafacade cartridge.
 >>
 >>UMLProfile.java
 >>---------------
 >>Instead of:
 >>public static final String STEREOTYPE_ENTITY = "Entity";
 >>
 >>you can use:
 >>public static final String STEREOTYPE_ENTITY =
 >>     ResourceBundle.getString("Entity");
 >>
 >>or so.
 >>
 >>And you have:
 >>
 >>UMLProfile.property
 >>-------------------
 >>Entity=Entity
 >>
 >>
 >>IMO, this only has to be done at the Metafacade cartridge,
 >>because this should be the foundation of all other cartridges.
 >>
 >>It doesn't mattter to other cartridges, since they depend on
 >>the developers of those cartridges.
 >>
 >>
 >>The !best! if we can centralized the constants (stereotypes,
 >>taggedvalues, constants, etc.) in one place, which we can
 >>refer from the:
 >>1. Implementation Code in Java (from Metafacade),
 >>2. andromda-metafacades.xml,
 >>3. andromda-cartridge.xml,
 >>4. Templates files,
 >>
 >>The cleanest solution would be:
 >>
 >>1. Add a new property in andromda-cartridge.xml, something like:
 >>
 >><constants>
 >>   <name="STEREOTYPE_EXCEPTION" value="Exception">
 >>   <name="STEREOTYPE_SERVICE" value="Service">
 >>   <name="STEREOTYPE_ENTITY" value="Entity">
 >>   <name="STEREOTYPE_FINDER_METHOD" value="FinderMethod">
 >>   <name="TAGGEDVALUE_PERSISTENCE_COLUMN" value=""@persistence.column">
 >>   ...
 >></constants>
 >>
 >>2. To access this values from our Java impl., we need a utility class,
 >>something like:
 >>
 >>String service = CartridgeUtil.getString("STEREOTYPE_SERVICE");
 >>
 >>3. To access this values from our Templates:
 >>
 >>#set ($service = cartridgeUtil.getString("STEREOTYPE_SERVICE"))
 >>
 >>Before, we need to add this "CartidgeUtil" into our andromda-cartridge
 >>something like:
 >>
 >><templateObject name="cartridgeUtil"
 >>     className="org.andromda.core.common.CartridgeUtil"/>
 >>
 >>4. In andromda-cartridge.xml and andromda-metafacades.xml
 >>we need to use the constant name and not the real name,
 >>something like:
 >>
 >>     <!-- Stereotype: entity -->
 >>     <template
 >>         sheet="templates/HibernateEntityAbstract.vsl"
 >>       outputPattern="{0}/{1}Abstract.java"
 >>     outlet="entities"
 >>     overWrite="true">
 >>         <modelElements variable="class">
 >>             <modelElement stereotype="STEREOTYPE_ENTITY"/>
 >>         </modelElements>
 >>     </template>
 >>
 >>and
 >>
 >>     <metafacade
 >>metaobjectClass="org.omg.uml.foundation.core.Operation$Impl"
 >>           metafacadeClass="org.andromda.cartridges.ejosa.
 >>           businessejbhibernate.metafacades.BusinessEjbHibernateFinder
 >>           MethodFacadeLogicImpl">
 >><stereotype>STEREOTYPE_FINDER_METHOD</stereotype>
 >>     </metafacade>
 >>
 >>
 >>Surely, all the cartidge developers must be very strict to this
 >>convention: never use a string like "Entity" directly in Java,
 >>Templates and everywhere else. Always use the constant defined
 >>in the andromda-cartridge.xml. In this way, it would be very
 >>easy to rename those stereotypes, taggedvalues, constants, etc.
 >>
 >>IMO, this would be really cool!
 >>
 >>Cheers,
 >>
 >>Writing the CartridgeUtil class is not a problem at all, I think.
 >>Just need to read andromda-cartridge.xml (and AndroMDA team has
 >>done this in AndroMDA a lot of time, right ;-))?
 >>
 >>--
 >>---------------------------------------------------
 >>Blasius Lofi Dewanto
 >>---------------------------------------------------
 >>OpenUSS - Open University Support System
 >>http://openuss.sourceforge.net
 >>---------------------------------------------------
 >>E-Mail   : [EMAIL PROTECTED]
 >>ICQ      : 39343280
 >>---------------------------------------------------
 >>
 >>Chad Brandon schrieb:
 >> > Hi Lofi,
 >> >
 >> > It would be great if it was that
 >> > simple...unfortunately some of the cartridges use the
 >> > hard coded values of stereotypes.   I'd really like to
 >> > do something clean with the stereotype names.  So that
 >> > its easy for people to configure them.
 >> >
 >> > Chad
 >> >
 >> > --- Lofi Dewanto <[EMAIL PROTECTED]> wrote:
 >> >
 >> >>Hi Community,
 >> >>
 >> >>I would like to whether it is possible to "rename"
 >> >>those Stereotypes, TaggedValues constants in the
 >> >>UMLProfile.java
 >> >>in my own cartridge?
 >> >>
 >> >>Example:
 >> >>
 >> >>In UMLProfile.java the STEREOTYPE_IDENTIFIER is
 >> >>defined
 >> >>as "PrimaryKey". I would like to use another name
 >> >>for
 >> >>this, like for example "primaryKey". Is this
 >> >>possible without
 >> >>modifying the Metafacade itself?
 >> >>
 >> >>Thanks!
 >> >>--
 >> >>---------------------------------------------------
 >> >>Blasius Lofi Dewanto
 >> >>---------------------------------------------------
 >> >>OpenUSS - Open University Support System
 >> >>http://openuss.sourceforge.net
 >> >>---------------------------------------------------
 >> >>E-Mail   : [EMAIL PROTECTED]
 >> >>ICQ      : 39343280
 >> >>---------------------------------------------------
 >> >>
 >> >>
 >> >>
 >> >>
 >> >>
 >> >
 >> > -------------------------------------------------------
 >> >
 >> >>This SF.Net email sponsored by Black Hat Briefings &
 >> >>Training.
 >> >>Attend Black Hat Briefings & Training, Las Vegas
 >> >>July 24-29 -
 >> >>digital self defense, top technical experts, no
 >> >>vendor pitches,
 >> >>unmatched networking opportunities. Visit
 >> >>www.blackhat.com
 >> >>_______________________________________________
 >> >>Andromda-user mailing list
 >> >>[EMAIL PROTECTED]
 >> >>
 >> >
 >> > https://lists.sourceforge.net/lists/listinfo/andromda-user
 >> >
 >> >
 >> >
 >>
 >>
 >
 >
 >

package org.andromda.metafacades.uml;

import java.util.ResourceBundle;

/**
 * Contains the common UML AndroMDA profile. That is, it contains elements
 * "common" to all AndroMDA components (tagged values, and stereotypes).
 * 
 * @author Chad Brandon
 */
public class UMLProfile {

        // Get the resource
        static ResourceBundle umlProfile = ResourceBundle
                        .getBundle("org.andromda.metafacades.uml.UMLProfile");

        /* ----------------- Stereotypes -------------------- */

        /**
         * Represents a persistent entity.
         */
        public static final String STEREOTYPE_ENTITY = umlProfile
                        .getString("STEREOTYPE_ENTITY");

        /**
         * Represents a finder method on an entity.
         */
        public static final String STEREOTYPE_FINDER_METHOD = umlProfile
                        .getString("STEREOTYPE_FINDER_METHOD");

        /**
         * Represents the primary key of an entity.
         */
        public static final String STEREOTYPE_IDENTIFIER = umlProfile
                        .getString("STEREOTYPE_IDENTIFIER");

        /**
         * Represents a service.
         */
        public static final String STEREOTYPE_SERVICE = umlProfile
                        .getString("STEREOTYPE_SERVICE");

        /**
         * The base exception stereotype. If a model element is stereotyped with
         * this (or one of its sub stereotypes), then it is excepted that a
         * cartridge will generate an exception
         */
        public static final String STEREOTYPE_EXCEPTION = umlProfile
                        .getString("STEREOTYPE_EXCEPTION");

        /**
         * Represents exceptions thrown during normal application processing (such
         * as business exceptions). It extends the base exception stereotype.
         */
        public static final String STEREOTYPE_APPLICATION_EXCEPTION = umlProfile
                        .getString("STEREOTYPE_APPLICATION_EXCEPTION");

        /**
         * Represents unexpected exceptions that can occur during application
         * processing. This that a caller isn't expected to handle.
         */
        public static final String STEREOTYPE_UNEXPECTED_EXCEPTION = umlProfile
                        .getString("STEREOTYPE_UNEXPECTED_EXCEPTION");

        /**
         * Represents a reference to an exception model element. Model dependencies
         * to unstereotyped exception model elements can be stereotyped with this.
         * This allows the user to create a custom exception class since the
         * exception itself will not be generated but the references to it will be
         * (i.e. the throws clause within an operation).
         */
        public static final String STEREOTYPE_EXCEPTION_REF = umlProfile
                        .getString("STEREOTYPE_EXCEPTION_REF");

        /* ----------------- Tagged Values -------------------- */

        /**
         * Represents documentation stored as a tagged value
         */
        public static final String TAGGEDVALUE_DOCUMENTATION = umlProfile
                        .getString("TAGGEDVALUE_DOCUMENTATION");

        /**
         * Represents a SQL table name for entity persistence.
         */
        public static final String TAGGEDVALUE_PERSISTENCE_TABLE = umlProfile
                        .getString("TAGGEDVALUE_PERSISTENCE_TABLE");

        /**
         * Represents a SQL table column name for entity persistence.
         */
        public static final String TAGGEDVALUE_PERSISTENCE_COLUMN = umlProfile
                        .getString("TAGGEDVALUE_PERSISTENCE_COLUMN");

        /**
         * Represents a SQL table column length
         */
        public static final String TAGGEDVALUE_PERSISTENCE_COLUMN_LENGTH = umlProfile
                        .getString("TAGGEDVALUE_PERSISTENCE_COLUMN_LENGTH");

}
# UMLProfile

# Stereotypes
STEREOTYPE_ENTITY=Entity
STEREOTYPE_FINDER_METHOD=FinderMethod
STEREOTYPE_IDENTIFIER=PrimaryKey
STEREOTYPE_SERVICE=Service
STEREOTYPE_EXCEPTION=Exception
STEREOTYPE_APPLICATION_EXCEPTION=ApplicationException
STEREOTYPE_UNEXPECTED_EXCEPTION=UnexpectedException
STEREOTYPE_EXCEPTION_REF=ExceptionRef

# Taggedvalues
TAGGEDVALUE_DOCUMENTATION=documentation
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Reply via email to