EMF Model ecore Diagram eclipse, how to do a two way relation - eclipse

I'm trying to do my first Model with ecore diagram and I didn't find a way to draw a relationship between two class with any direction on it. In other words, any arrow symbol on the extremity of it.
Is it possible and how to do it?

Create a reference from the first class to the second. Call it ref1, for example. Then create another reference in the opposite direction - from the second class to the first - and set its "opposite" property to ref1.

Related

How to inherit a standard Fluid component and override and replace some equations of the base model?

I want to customize a standard Fluid Library component in Modelica using OpenModelica. 
I want to create a customized version of a new Pump where several equations will be changed.
I inherited Fluid.Machines.BaseClasses.PartialPump as a base model by "extends" keyword. When I tried to change and redefine an equation, it gave an overdetermined system error. 
I put redeclare or redifine in front of the equation, and it still gives an error.
What is the best way to create a customised component model without copying everything into a new model? 
Thanks
Unfortunately, you cannot change existing code* — you can only add new code.
In your case, you will have to make a copy of Fluid.Machines.BaseClasses.PartialPump and modify the equation in question. However, you don't necessarily need to copy its base class (Modelica.Fluid.Interfaces.PartialTwoPort).
The PartialPump model is quite versatile. If you need different pump curves (pressure, efficiency or power) you can write additional functions based on the base classes in Fluid.Machines.BaseClasses.PumpCharacteristics.
*) One exception to my initial statement is the inheritance of graphical annotations: if you extend a model and add the annotation primitivesVisible=false the graphical annotations (icon) will not be inherited, for example:
model myModel
extends baseModel annotation(IconMap(primitivesVisible=false));
<new icon annotations>
end myModel;
The usage of extends suggests one wants to inherit all the behaviours of the extended class. You can change those behaviours unless they are redeclarable. The best is to create a new class by duplicating the base model and then change the behaviours as you want. Hope this works!

Contract multiple similar attributes in UML

In school we should draw an UML class diagramm for a class we plan to write (we should do the planning).
I now have 10 JLabels, which are attributes to the class Game and each showing a different picture, but all off them serving the same purpose. To keep it a bit clearer, the Labels will be called Player1Throw1 to Player1Throw5 and Player2Throw1 to Player2Throw5.
My question is, if there is a correct way in UML to contract these 10 labels, so that I don't have to write
Game
--------
-Player1Throw1: JLabel
-Player1Throw2: JLabel
-Player1Throw3: JLabel
-Player1Throw4: JLabel
-Player1Throw5: JLabel
-Player2Throw1: JLabel
-Player2Throw2: JLabel
-Player2Throw3: JLabel
-Player2Throw4: JLabel
-Player2Throw5: JLabel
Or in other words: Is there a way to contract these 10 lines in maybe 2 lines?
Thanks for any help!
You could use the following notation in UML:
- Player1Throw : JLabel[5]
- Player2Throw : JLabel[5]
You should be able to generate code from the class diagram. How will you be able to do it when you do not define all the attributes separately? If you can answer that question, you know how to display them.
Designing in OOP is trying to find out if you can make the behavior more abstract. If you have 10 likewise labels, can you then make another set of classes based on a shared interface that can do the job as well? Dive into design patterns. There is a pattern that is made for this situation.
Don't use global variables for local attributes.
On code level use collections (arrays, sets, bags, etc.) for multiple objects of the same role.
You should define a class Player (which as I understand is a part of Game) and class Game should contain a collection (array?) player of two objects of type Player.
Player should have an attribute throw with multiplicity 5 (or maybe 0..5 - I don't know details of your project, however on code level it doesn't really impact class structure) of type JLabel.
Thus your UML class diagram will look like that

Working with Swift and Core Data

This is more of a generalized question as I have yet to write the code for the question I am asking. Before I get started writing the code I wanted to make sure I am on the right track and possibly getting suggestions for better ways to do what I want to do. Basically right now I have a core data model setup in a way that I think is correct for what I am trying to do and just need some guidance on a very specific part of the code but want to make sure overall I created it correctly.
The first part to the question is more of a clarification on how relationships work in core data. Right now I have 5 entities and to make sure I have the correct idea on how it works I will use a few examples to make sure I am on the right track.
So lets save I have an entity I called name. Within that Name entity that contains only a name attribute. Next I have an entity that has classes, that each have a boolean of true or false to determine which class it is. These 2 are related in a inverse relationship of Name entity having a to one relationship and the Classes having a to many relationship because multiple names can have multiple classes but each name can only have 1 class. If I am right on this one that means I full understand core data relationships!
Now the second part of the question is related to the booleans in the class. I have the Class entity which is like I said a boolean containing a true false set as default to false. When the user selects one of the class buttons before presenting the popover where they actually give the name of the class selected it saves the boolean to true then passes that data over to the popover Name view controller. I am very unsure as to how to do this as it isn't a widely asked question on here nor have I been able to find any info through researching. I am one of those people who needs to actually learn by clear examples....any help with this would be appreciated! Sorry I don't have any example code for this.
The first part seems correct. The ManagedObject of your Class CoreDataObject should have an NSSet property which will contain the names (as the Class can have multiple names)
For the second part, Core Data uses objects. When you 'get' the data from Core Data it will be a (probably extended) NSManagedObject (named Class in our case). You can send this object as a parameter just as you would do with any other object and use it as you would use any other object :-). For example looping over de NSSet Names
func iterateOverNames(someClass: Class) {
for name: Name in someClass.names {
// do stuff
}
}
You can check these links for more information:
https://realm.io/news/jesse-squires-core-data-swift/
https://developer.apple.com/library/ios/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/index.html

How to use properties from a child in EMF

I have a sample EMF hierarchy like this -
Parent : Shape
Child 1 : Circle
Child 2 : Square
Child 3 : Rect
Now I want to generate my properties view in Eclipse in such a way that . I have a drop down with ShapeType and based on the shape type I want to show the properties of the child element.
Essentially I want to display/edit the child properties based on the 'type' selection in the parent.
Any thoughts how I can achieve this?
You cannot solve this issue easily, as in that case the dropdown needs to change the EMF type of an object, that results in Java class changes. To have such thing working, you have to create a new EObject instance, copy all relevant attributes, and remove the old object (and possibly update the selection).
So, alltogether, I believe, what you want is not possible with basic EMF tooling, however, if you provide a custom model manipulation commands, it should be possible.
Other things, you can try (if possible in your domain):
Move all your data to properties of the parent object, add EValidators to prevent inconsistent states from appearing, and update the default EMF Edit commands to filter out unnecessary editors. Ugly, but may work.
Create custom forms/editors, that manage the object removal/addition during the manually coded editing process.

Using an interface classifier in a UML Class Diagram

I am trying to implement an UML Class Diagram and I would like to use an interface classifier CreateItem to inform a developer that (that rappresents an input web form), in order to populate an attribute TitleI in a class Item, he/she MUST use one or more TitleO of a class Object. That is, I would like to indicate that using a web form CreateItem you can "compose" a Item TitleI (TitleI is a string) exclusively searching and adding to it one or more Object TitleO (TitleO is a string).
It should working as "composing" the StackOverflow Tags "string" when you Ask a new question. The only difference is that I would like to create a Title string made by those Tags.
I "learned" to solve part of my issue in thinking this way:
< < interface > > **CreateItem** is a *realization* of **Item**
Then?
You can depict the composition/aggregation using respective relationships. You can use the dependency relationship to depict creation. If this doesn't help, try to formulate your question in other way or to be more precise and I will try to answer.