Skip to main content



      Home
Home » Modeling » UML2 » isAttribute always returns false
isAttribute always returns false [message #1052848] Tue, 30 April 2013 13:15 Go to next message
Eclipse UserFriend
Hi,

Shouldn't the output of isAttribute be "true" on the following code, or is it that I don't understand the meaning of isAttribute. I'm using UML 4.0.2. Thanks!

Property p = UMLFactory.eINSTANCE.createProperty();
Class c = UMLFactory.eINSTANCE.createClass();

c.getOwnedAttributes().add(p);
System.out.println(c.getAttributes().contains(p)); // true
System.out.println(p.isAttribute(p)); // false

--
Hector
Re: isAttribute always returns false [message #1052935 is a reply to message #1052848] Wed, 01 May 2013 09:25 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The manual code for the OCL: result = Classifier.allInstances->exists(c
| c.attribute->includes(p))
is:

public static boolean isAttribute(Property property, Property p) {

for (EStructuralFeature.Setting nonNavigableInverseReference :
getNonNavigableInverseReferences(p)) {
EObject eObject = nonNavigableInverseReference.getEObject();

if (eObject instanceof Classifier
&& ((Classifier) eObject).getAttributes().contains(p)) {

return true;
}
}

return false;
}

expects p to be well-formed in order to use non-navigable navigation
rather than a brute force allInstances. You have omitted the
Property.type definitions, so the navigation fails. (I'm unclear how
well navigable associations will work; you might want to nraise a Bugzilla.)

Regards

Ed Willink



On 30/04/2013 18:15, Hector Chavez wrote:
> Hi,
>
> Shouldn't the output of isAttribute be "true" on the following code,
> or is it that I don't understand the meaning of isAttribute. I'm using
> UML 4.0.2. Thanks!
>
> Property p = UMLFactory.eINSTANCE.createProperty();
> Class c = UMLFactory.eINSTANCE.createClass();
>
> c.getOwnedAttributes().add(p);
> System.out.println(c.getAttributes().contains(p)); // true
> System.out.println(p.isAttribute(p)); // false
> --
> Hector
Re: isAttribute always returns false [message #1052960 is a reply to message #1052935] Wed, 01 May 2013 11:19 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Ed,

I modified the example to have well formed properties and I still get the same result. Do you know of any case of a non-navigable attribute that would make isAttribute return true?

...

Class car = rootPackage.createOwnedClass("Car", false);
Class gas = rootPackage.createOwnedClass("Gas", false);

PrimitiveType type = rootPackage.createOwnedPrimitiveType("String");
Property name = car.createOwnedAttribute("name", type, 1, 1);

System.out.println(name.isAttribute(name)); // false

Association assoc = car.createAssociation(true,
			AggregationKind.NONE_LITERAL, "needs", 0, 1, gas, false,
			AggregationKind.NONE_LITERAL, "car", 0, 1);

Property car_needs = assoc.getMemberEnd("needs", gas);
Property gas_car = assoc.getMemberEnd("car", car);

System.out.println(car_needs.isAttribute(car_needs)); //false
System.out.println(gas_car.isAttribute(gas_car)); //false


Thanks.
Re: isAttribute always returns false [message #1052962 is a reply to message #1052960] Wed, 01 May 2013 11:23 Go to previous messageGo to next message
Eclipse UserFriend
Hi

My comment on navigability was just based on reading the code without
following up the specifications of the called routines.

It looks as if the assumption was that no one would call isAttribute for
navigable attributes since that would be redundant. This seems wrong
with respect to UML 2.5; hence my suggestion to raise a Bugzilla.

Regards

Ed Willink


On 01/05/2013 16:19, Hector Chavez wrote:
> Thanks Ed,
>
> I modified the example to have well formed properties and I still get
> the same result. Do you know of any case of a non-navigable attribute
> that would make isAttribute return true?
>
> ..
>
> Class car = rootPackage.createOwnedClass("Car", false);
> Class gas = rootPackage.createOwnedClass("Gas", false);
>
> PrimitiveType type = rootPackage.createOwnedPrimitiveType("String");
> Property name = car.createOwnedAttribute("name", type, 1, 1);
>
> System.out.println(name.isAttribute(name)); // false
>
> Association assoc = car.createAssociation(true,
> AggregationKind.NONE_LITERAL, "needs", 0, 1, gas, false,
> AggregationKind.NONE_LITERAL, "car", 0, 1);
>
> Property car_needs = assoc.getMemberEnd("needs", gas);
> Property gas_car = assoc.getMemberEnd("car", car);
>
> System.out.println(car_needs.isAttribute(car_needs)); //false
> System.out.println(gas_car.isAttribute(gas_car)); //false
>
>
> Thanks.
Re: isAttribute always returns false [message #1053015 is a reply to message #1052962] Wed, 01 May 2013 19:26 Go to previous message
Eclipse UserFriend
Thanks, I just submitted the bug report.
Previous Topic:creating association in uml profiles
Next Topic:Specifying an action of a transition
Goto Forum:
  


Current Time: Wed Jul 02 18:32:38 EDT 2025

Powered by FUDForum. Page generated in 0.05014 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top