Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for adding a child that is typed by a polymorphic association #12

Closed
abstratt opened this issue Dec 2, 2015 · 10 comments
Closed

Comments

@abstratt
Copy link
Owner

abstratt commented Dec 2, 2015

Add support for adding a child object that is typed by a polymorphic association.

Right now we try to use a type that maybe subclassed and either don't offer the user a chance to choose a type that is more specific, or fail due to the type not being instantiable.

@abstratt
Copy link
Owner Author

abstratt commented Dec 2, 2015

@atanaka This is the issue you saw when trying to add a child party to an organization. We try to create an empty Party (or template object), for default values etc, but since it is abstract, that fails.

@abstratt
Copy link
Owner Author

abstratt commented Dec 2, 2015

Depends on abstratt/cloudfier#87.

@abstratt
Copy link
Owner Author

abstratt commented Jan 3, 2016

Example:

image

@atanaka
Copy link

atanaka commented Jan 3, 2016

Hello,

Could you provide sample model code to produce above? Did you use Composition or Association?

Thank you in advance.
Regards,
Akira

@abstratt
Copy link
Owner Author

abstratt commented Jan 3, 2016

Hi @atanaka san, happy new year!

I used aggregation:

package sample;

abstract class Party
    attribute name : String;
end;

class Person specializes Party
    attribute firstName : String;
end;

class Organization specializes Party
    attribute registeredCode : String;
end;

aggregation Organization2Party
    navigable role parties : Party[*];
    navigable role organization : Organization[0,1];
end;

end.

I opened #13 to handle the association case. I noticed too the composition case is not working well (the entities are not considered top-level and as such disappear from the navigation bar). There may other cases not properly handled yet.

@atanaka
Copy link

atanaka commented Jan 3, 2016

Happy New Year! Thanks for the response.

Your model code did not work under my environment. What I did and happened was:

  1. I created two Person instances, P1 and P2,
  2. I created two Company instances, C1 and C2, and
  3. I opened instance C1 (as editable) and tried to add instance P1 and instance C2.
    When I click on + mark on Person, I got popup window for adding Person as Party (that's correct behavior) and I was able to add P1, but that P1 was added as a new Person instance to existing (P1, P2) list, resulting in (P1,P2,P1) list.

Did I miss something? Thank you for your time in advance.
Regards,
Akira

@abstratt
Copy link
Owner Author

abstratt commented Jan 3, 2016

Akira, in this case persons and organizations may exist regardless whether they are part of an organization or not (the parent relationship is optional - [0..1]). That is why you see the new P1 person in the persons list. Similar case:

image

It seems you expected child persons/organizations that belong to an organization not to show as part of the global listings of persons and organizations. That may be something worth considering, but I would be a feature on its own. If the lack of such feature blocks a use case you have, please open an issue explaining it.

A way of achieving what you expect now would be to add a query to filter persons by whether they are part of an organization or not. Here is the updated model:

abstract class Party
    attribute name : String;
    attribute organization : Organization[0,1];
end;

class Person specializes Party
    attribute firstName : String;
    static query independentOnly() : Person[*];
    begin
        return Person extent.select((p : Person) : Boolean { p.organization == null });
    end;
end;

class Organization specializes Party
    attribute registeredCode : String;
end;

aggregation Organization2Party
    navigable role parties : Party[*];
    role Party.organization;
end;

image

Note that because of abstratt/textuml#89 I had to convert the organization association end to a member-owned end (it was association-owned initially). Also, because of #15, the organization for a person/suborganization no longer shows on the list view.

@abstratt
Copy link
Owner Author

abstratt commented Jan 3, 2016

@atanaka Not sure you got a notification for my reply above, I forgot to mention your github handle.

@atanaka
Copy link

atanaka commented Jan 4, 2016

Thank you for quick response.

Akira, in this case persons and organizations may exist regardless whether they are part of an organization or not (the parent relationship is optional - [0..1]). That is why you see the new P1 person in the persons list.

That is fine and that is what I expected. I would try to explain more below.

When I click + mark on Party(Person) from Organization instance, I expect to see a list of all registered (or already created) Person instances as candidates (shown by content assist). But actually I do not see any candidate Person instances. I do not know if this is the expected behavior or an issue.

Also, when Person class and Organization class are treated as master class, they may be created and maintained independently, and when new organization is added, selected and existing persons will be added as members of that organization at that creation time. That's why I expected to see candidate list with content assist. I understand that this may be a special use case.

I would appreciate if you could clarify on this point (your design choice or an issue).

Thank you very much in advance.
Regards,
Akira

@abstratt
Copy link
Owner Author

abstratt commented Jan 4, 2016

@atanaka Oh, I see now. What you want is possible if you declare the association as a a regular association. In that case, instead of adding new ones, you would be allowed to choose a candidate list of existing instances to add as a related instance. Except I think I need to address #13 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants