Login | Register
My pages Projects Community openCollabNet

Discussions > modules-dev > Re: [argouml-modules-dev] get model elements in the class diagram

argouml
Discussion topic

Hide all messages in topic

All messages in topic

Re: [argouml-modules-dev] get model elements in the class diagram

Author Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Full name Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Date 2005-11-16 19:43:39 PST
Message Bob Tarling wrote:

>Silly me. Try
>
> String packageName = "";
> Object ns = Model.getFacade().ge​tNamespace(myElement​)
> while (Model.getFacade().i​sAPackage(ns)) {
> if (packageName.length != 0) packageName = "." + packageName;
> packageName = Model.getFacade().getName(ns) + packageName;
> }
>
>On 11/12/05, Bob Tarling <bob dot tarling at gmail dot com> wrote:
>
>
>>I don't know of any utilities at the moment (although others may correct me)
>>
>>For each model element returned you will have to something like
>>(haven't tested) -
>>
>> String packageName = "";
>> Object ns = Model.getFacade().ge​tNamespace(myElement​)
>> while (Model.getFacade().i​sAPackage(ns)) {
>> if (packageName.length == 0) packageName += ".";
>> packageName += Model.getFacade().getName(ns);
>> }
>>
>>then test the packageName and reject as you wish.
>>
>>Guys - do we have any need for something like this, or have already?
>>Would it be a sensible addition to the model interface
>>
>>e.g. Model.getFacade().ge​tQualifiedName(myEle​ment);
>>
>>
>>Bob.
>>
>>
>>
>
>----------------​--------------------​--------------------​-------------
>To unsubscribe, e-mail: modules-dev-unsubscr​ibe at argouml dot tigris.o​rg
>For additional commands, e-mail: modules-dev-help@arg​ouml.tigris.org
>
>
>
Cool
Just in case someone wants to do something similar, this is what I did
based on Bob's suggestion
        Collection elements =
modelMgmt.getAllMode​lElementsOfKindWithM​odel(model,
metaTypes.getUMLClass() );
        Collection classes = new ArrayList();
        //filter out all the classes I dont need
        Iterator itr = elements.iterator();
        while(itr.hasNext()){
            Object element = itr.next();
            Vector path = modelMgmt.getPath(element);
            String topMostPackage = (String)path.elementAt(0);
            if(topMostPackage.st​artsWith("java") ||
topMostPackage.start​sWith("ossj") || topMostPackage.start​sWith("org")){
                continue;
            else
                classes.add(element);
        }
        logger.info("returned Classes = "+classes);
        return classes;

Thanks everyone (Bob)
Thapelo

Re: [argouml-modules-dev] get model elements in the class diagram

Author Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Full name Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Date 2005-11-12 08:44:09 PST
Message Bob Tarling wrote:

>I don't know of any utilities at the moment (although others may correct me)
>
>For each model element returned you will have to something like
>(haven't tested) -
>
> String packageName = "";
> Object ns = Model.getFacade().ge​tNamespace(myElement​)
> while (Model.getFacade().i​sAPackage(ns)) {
> if (packageName.length == 0) packageName += ".";
> packageName += Model.getFacade().getName(ns);
> }
>
>then test the packageName and reject as you wish.
>
>Guys - do we have any need for something like this, or have already?
>Would it be a sensible addition to the model interface
>
>e.g. Model.getFacade().ge​tQualifiedName(myEle​ment);
>
>
>Bob.
>
>----------------​--------------------​--------------------​-------------
>To unsubscribe, e-mail: modules-dev-unsubscr​ibe at argouml dot tigris.o​rg
>For additional commands, e-mail: modules-dev-help@arg​ouml.tigris.org
>
>
>
O'rite, I've tried that but I doesnt quite work as expected but @least
it gave me an idea. I'll scratch ma head a lil bit more and see if I can
come up wit something, I'll let you know if anything.
Cheers mate
Thapelo

Re: [argouml-modules-dev] get model elements in the class diagram

Author bobtarling
Full name Bob Tarling
Date 2005-11-12 07:14:17 PST
Message Silly me. Try

  String packageName = "";
  Object ns = Model.getFacade().ge​tNamespace(myElement​)
  while (Model.getFacade().i​sAPackage(ns)) {
    if (packageName.length != 0) packageName = "." + packageName;
    packageName = Model.getFacade().getName(ns) + packageName;
  }

On 11/12/05, Bob Tarling <bob dot tarling at gmail dot com> wrote:
> I don't know of any utilities at the moment (although others may correct me)
>
> For each model element returned you will have to something like
> (haven't tested) -
>
> String packageName = "";
> Object ns = Model.getFacade().ge​tNamespace(myElement​)
> while (Model.getFacade().i​sAPackage(ns)) {
> if (packageName.length == 0) packageName += ".";
> packageName += Model.getFacade().getName(ns);
> }
>
> then test the packageName and reject as you wish.
>
> Guys - do we have any need for something like this, or have already?
> Would it be a sensible addition to the model interface
>
> e.g. Model.getFacade().ge​tQualifiedName(myEle​ment);
>
>
> Bob.
>

Re: [argouml-modules-dev] get model elements in the class diagram

Author bobtarling
Full name Bob Tarling
Date 2005-11-12 07:09:53 PST
Message I don't know of any utilities at the moment (although others may correct me)

For each model element returned you will have to something like
(haven't tested) -

  String packageName = "";
  Object ns = Model.getFacade().ge​tNamespace(myElement​)
  while (Model.getFacade().i​sAPackage(ns)) {
    if (packageName.length == 0) packageName += ".";
    packageName += Model.getFacade().getName(ns);
  }

then test the packageName and reject as you wish.

Guys - do we have any need for something like this, or have already?
Would it be a sensible addition to the model interface

e.g. Model.getFacade().ge​tQualifiedName(myEle​ment);


Bob.

Re: [argouml-modules-dev] get model elements in the class diagram

Author Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Full name Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Date 2005-11-12 06:35:12 PST
Message Bob Tarling wrote:

>Are you sure about this - ie onlt elements in a diagram?
>It's quite possible to create your own model elements that are not on
>a diagram but still make up part of the model.
>You can also have the same model element on more than one diagram.
>If you want to get rid of the java classes from the list then you
>should filter out model elements from specific packages.
>Possibly someone familiar with our own code generation may be able to
>suggest existing functionality to do just that.
>
>Bob.
>
>----------------​--------------------​--------------------​-------------
>To unsubscribe, e-mail: modules-dev-unsubscr​ibe at argouml dot tigris.o​rg
>For additional commands, e-mail: modules-dev-help@arg​ouml.tigris.org
>
>
>
Hi Bob
How can I actually filter the classes from java packages? Is there a
utility/helper class that I can use to do that in the argouml ?
Thank you

Re: [argouml-modules-dev] get model elements in the class diagram

Author bobtarling
Full name Bob Tarling
Date 2005-11-12 05:02:16 PST
Message Are you sure about this - ie onlt elements in a diagram?
It's quite possible to create your own model elements that are not on
a diagram but still make up part of the model.
You can also have the same model element on more than one diagram.
If you want to get rid of the java classes from the list then you
should filter out model elements from specific packages.
Possibly someone familiar with our own code generation may be able to
suggest existing functionality to do just that.

Bob.

Re: [argouml-modules-dev] get model elements in the class diagram

Author Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Full name Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Date 2005-11-12 04:00:22 PST
Message Bob Tarling wrote:

>>Classes that are depicted by my Class Diagram
>>
>>
>Are you only looking for classes on your diagram? The current diagram?
>
>Bob
>
>----------------​--------------------​--------------------​-------------
>To unsubscribe, e-mail: modules-dev-unsubscr​ibe at argouml dot tigris.o​rg
>For additional commands, e-mail: modules-dev-help@arg​ouml.tigris.org
>
>
>
yes Bob, only the classes I have modelled myself not the Java classes

Re: [argouml-modules-dev] get model elements in the class diagram

Author bobtarling
Full name Bob Tarling
Date 2005-11-12 03:30:25 PST
Message >Classes that are depicted by my Class Diagram
Are you only looking for classes on your diagram? The current diagram?

Bob

get model elements in the class diagram

Author Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Full name Thapelo Tlhong <tt102 at ecs dot soton dot ac dot uk>
Date 2005-11-11 19:47:57 PST
Message Hi everyone
I'm working on UML plugin for Java code generation using Velocity. I was
wondering, how can I actually get the model elements from the current
model, What I currently have is
/*get all the model elements of type Class in the model*/
ModelManagementHelper modelMgmt = Model.getModelManage​mentHelper();
Collection classes = classes =
modelMgmt.getAllMode​lElementsOfKindWithM​odel(model,
metaTypes.getUMLClass() );
. . .
/*iterate over the elements extracting the attributes, operation etc */

But this returns me even the Java classes which have been declared as a
type for some attributes or operations in the model. What I want is to
only return those Classes that are depicted by my Class Diagram

Thanks you all
Thapelo
Messages per page: