eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

InstanceSpecification of association not handled correctly in OCL #353

Closed eclipse-ocl-bot closed 1 month ago

eclipse-ocl-bot commented 1 month ago

| --- | --- | | Bugzilla Link | 259630 | | Status | CLOSED FIXED | | Importance | P3 normal | | Reported | Dec 24, 2008 07:39 EDT | | Modified | May 27, 2011 02:47 EDT | | Version | 1.2.0 | | Reporter | Bas Elzinga |

Description

Build ID: I20080617-2000

Steps To Reproduce:

  1. Create two classes with a navigable association between them
  2. Create the instances of the two classes and a link(InstanceSpecification) for the assiociation between those instances
  3. Use the link in ocl from the nonnavigable side: self.toOtherClass
  4. It returns itself which is incorrect

More information:\ Debugging through ocl I came across the following code which might contain the problem:

org.eclipse.ocl.uml.UMLEvaluationEnvironment.java

navigateNonNavigableProperty(Property, Association, InstanceSpecification)

/**
 * Navigates a non-navigable property in an instance specification context.\
 * 
 * @param property
 *            the non-navigable property to navigate
 * @param association
 *            the association of which the property is a member
 * @param instance
 *            the instance specification from which we are navigating the
 *            property\
 * 
 * @return the property value\
 */\
private Object navigateNonNavigableProperty(Property property,\
        Association association, InstanceSpecification instance) {\
    Collection<InstanceSpecification> result = CollectionUtil
        .createNewSet();

    Property otherEnd = property.getOtherEnd();

    for (Slot slot : getSlotsReferencing(instance)) {\
        // TODO: Handle redefinition of the other end\
        if (slot.getDefiningFeature() == otherEnd) {\
            InstanceSpecification referencer = slot.getOwningInstance();

            if (referencer != null) {\
                if (isInstance(association, referencer)) {\
                    // get value of the other end. Multiplicity of an\
                    // association end is always 1 from the association's\
                    // perspective

                    Slot otherSlot = getSlot(referencer, otherEnd);\

Should be: \ Slot otherSlot = getSlot(referencer, property);

                    if (otherSlot != null) {\
                        ValueSpecification value = otherSlot.getValues()
                            .isEmpty() ? null\
                            : otherSlot.getValues().get(0);\
                        if ((value != null)\
                            && (value instanceof InstanceValue)) {\
                            result.add(((InstanceValue) value)
                                .getInstance());\
                        }\
                    }\
                } else {\
                    // navigable opposite\
                    result.add(referencer);\
                }\
            }\
        }\
    }

    return coerceValue(property, result, true);\
}

But I could be wrong :) could someone look at it?

eclipse-ocl-bot commented 1 month ago

By Christian Damus on Dec 30, 2008 06:22

Nope, you're not wrong.

eclipse-ocl-bot commented 1 month ago

By Christian Damus on Dec 30, 2008 06:38

Suggested change is committed to HEAD (1.3 branch), along with a JUnit test that reproduces the problem scenario.

This sounds like a candidate for fixing in the Ganymede SR2 coming up in February. Please comment if this would be useful to you.

eclipse-ocl-bot commented 1 month ago

By Bas Elzinga on Dec 31, 2008 05:09

Yes that would be useful to us, thanks

eclipse-ocl-bot commented 1 month ago

By Anthony Hunter on Jan 06, 2009 10:06

(In reply to comment #2)

This sounds like a candidate for fixing in the Ganymede SR2 coming up in February. Please comment if this would be useful to you.

Hi Christian, can you confirm you are going to do this?

eclipse-ocl-bot commented 1 month ago

By Christian Damus on Jan 06, 2009 10:08

(In reply to comment #4)

(In reply to comment #2)

This sounds like a candidate for fixing in the Ganymede SR2 coming up in February. Please comment if this would be useful to you.

Hi Christian, can you confirm you are going to do this?

Are you voting for it? It seems a severe problem (basically, inverse navigation doesn't work at all in instance models) so, yes, I am planning to port the fix to GanySR2.

eclipse-ocl-bot commented 1 month ago

By Christian Damus on Jan 07, 2009 09:04

Committed the fix and unit test (incl. porting the test model to UML 2.1.0 schema version) to R1_2_maintentance (1.2.3 branch).

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Dec 15, 2010 13:30

This is a change of one symbol name.

Thank you for spotting the problem, but the change is not sufficient to contribute to the IP log.

eclipse-ocl-bot commented 1 month ago

By Ed Willink on May 27, 2011 02:47

Closing after over 18 months in resolved state.