hannesN / onotoa

a visual editor for the Topic Maps Constraint Language.
0 stars 0 forks source link

Strange Code Generation for Topic Relationsship #231

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Intro: Simple Example Project in Eclipse using two Topics and one Association 
between them with "Java Source Code Generation" in mind according to the 
tutorial.

What steps will reproduce the problem? According to the Eclipse Online 
Help/Tutorial ...
1. Created two topics (Person, Company) and two roles (Employer, Employee) and 
one association
2. Connected topics using a "works-for" association with the two roles
3. Set cardinalities as shown in tutorial (Company Player [1..1], Employer Role 
[1..1], Employee Role [1..1], Person Player [1..*]. The main case we had in 
mind was like "many person could work for a company"
  3a) Note 1: The tutorial shows screenshots "Figure 12.8." an "Figure 12.10." with different "company player cardinality" where only the second seems to be correct (slight mistake?)
  3b) Note 2: In the above example the "employee role cardinality" [1..*] as mentioned in the tutorial leads to a NullPointerException when trying to generate as long as not being set to cardinality [1..1].
4. Specified SI for all elements
5. File > Export > Aranuka Code Generation ...

What is the expected output?
Two java classes resp. files with following relationsship
a) class "Company" containing a Set (or List) of "Person"s
b) class "Person" containing a single reference (back) to a (the Person's) 
"Company"

What do you see instead?
Two java classes resp. files (Company and Person), but ...
a) class Company contains a single property "Person"
b) class Person contains a "Set of Companies"
=> which seems to be the contrary generated relationship!?

What version of the product are you using?
Onotoa PlugIn in Eclipse, Version 1.2.0.201104291532 (direct download from your 
project home website)

On what operating system?
Windows XP Prof. SP3

Please provide any additional information below.
Please see the attachment - this is our example project file we used for the 
above described case (*.ono file an both java classes)

So ... what's going on here. Did we understand something completly wrong 
(cannot be excluded ;-)) or could this be an error?

Original issue reported on code.google.com by eckst...@juwi.de on 29 Jul 2011 at 7:15

Attachments:

GoogleCodeExporter commented 9 years ago
Glad to here someones using Onotoa  :)
To you issue:
You schema says: I want one association per company with one employer and one 
employee. In addition you allow Persons to be in more works for relatioships.
So in other words: A company has one employer and a person may work for a lot 
of companies, but at least one. I guess that's not what you wanted ;)

The cardinalities for the roles say how much players playing the specific role 
are allowed in one association. I advise the usage of 1..1 like you did. 

The other cardinality (next to the player type) says how often an instance of 
the type may play in associations with the given type.

If you want a company to have more than one employee you need to set card-max 
of the Topic Role Constraint to *. With that the same company must be at least 
one times in an association typed "Works for" but may be more.

If a person may only work for one company you need to set the card-max of its 
topic role constraint to 1.

With that the source code should generate like you expected.

BTW: If you don't want the cross referencing, you can deactivate the attribute 
generation using annotations.

Hope this helps, if not feel free to mail me or better use the google group.

Original comment by h.niederhausen@googlemail.com on 29 Jul 2011 at 7:42