Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 277662

Summary: 'New JPA entity' wizard should accept short names for attribute types
Product: [WebTools] Dali JPA Tools Reporter: Stefan Dimov <stefan.dimov>
Component: FrameworkAssignee: Neil Hauge <neil.hauge>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: dimitar.giormov, kiril.mitov, neil.hauge
Version: unspecifiedKeywords: plan
Target Milestone: 2.3 M2   
Hardware: All   
OS: All   
Whiteboard: EaseOfUse
Attachments:
Description Flags
Allow entity PK of any type
none
Allow entity PK of any type V2
none
Version 3 of the patch neil.hauge: iplog+

Description Stefan Dimov CLA 2009-05-25 06:13:11 EDT
The 'New JPA entity' wizard allows the user to create attributes. A small dialog opens, which requires type and name for the attribute. If the type is a class, its fully qualified name is required, which is Ok, except, may be, for the commonly used classes.  

Maybe, it's a good idea, all of the classes belonging to java.lang package to be accepted without typing their fully qualified names - just the short ones!
Comment 1 Stefan Dimov CLA 2009-05-25 08:20:11 EDT
Maybe, it needs a little clarification: Actually, the wizard accepts any types. Even non-existing. The problem is that when you enter the type 'String' (short name only) the wizard accepts it and creates the java source without problems, but since this type was entered with short name only, the wizard doesn't recognize it as 'java.lang.String' and since not any class is allowed to be a type of an ID attribute, the wizard doesn't allow this attribute to be marked as ID. So, the request is actually the wizard not only to accept, but also to recognize the java.lang classes without typing their packages and thus allow this attributes to be marked as ID.
Comment 2 Neil Hauge CLA 2009-05-26 17:28:03 EDT
It might make more sense to just allow users to pick any field as an ID, but have a status warning in the dialog indicating the problem with this.  As an aside, we are missing this general validation outside of the wizard.

The current UI of having a disabled, non-grayed check-box that the user cannot check for these invalid ID fields is awkward.  We should at least be making it clear that these fields are not an option for ID if we are not going to let the user select them.



Comment 3 Stefan Dimov CLA 2009-08-04 11:16:19 EDT
Created attachment 143401 [details]
Allow entity PK of any type 

1. Allows the user to enter java.lang classes with their short names (String, Long)
2. Allows attribute with any type to be marked as PK
3. If a certain attribute is marked as PK, but its type is not appropriate, shows warning in the wizard
4. The attribute type combo-box in the small dialog is replaced by a text box
5. The attribute type text box is enriched with auto-completion for the basic primitives and allowed types
Comment 4 Neil Hauge CLA 2009-08-04 11:28:02 EDT
Thanks for the patch Stefan.  The described behavior sounds good - I'll take a look and test this out.
Comment 5 Neil Hauge CLA 2009-08-04 16:06:58 EDT
In this patch the wizard seems to have problems handling primitives and fully qualified attribute types.  Short names appear to be working well, but I can't get a primitive of fully qualified type to be set in the Entity fields table.


Also, a couple of items I noticed reviewing the code:

EntityDataModelProvider

I'm guessing this was a typo:
if (propertyName.equals(ENTITY_FIELDS) || propertyName.equals(ENTITY_FIELDS)) {

EntityRow

- might want to consider breaking up the setFqnTypeName into smaller chunks to help with the complexity of this method.
Comment 6 Stefan Dimov CLA 2009-08-05 04:00:58 EDT
Created attachment 143476 [details]
Allow entity PK of any type V2
Comment 7 Neil Hauge CLA 2009-08-06 11:28:03 EDT
The second patch appears to be working well.  I think the auto-completion is a big improvement over the combo box.  I'm going to do some more testing today and will commit the patch assuming that I don't find any other issues.  Thanks.
Comment 8 Neil Hauge CLA 2009-08-06 16:50:35 EDT
Moving to M2 since the WTP schedule moved up one week for M1.
Comment 9 Stefan Dimov CLA 2009-08-18 11:04:25 EDT
Created attachment 144834 [details]
Version 3  of the patch

Improvements of the previous patch:

1. When an attribute of an invalid simple primary key type is checked as an id the message is error instead of warning
2. The text of the error message mentioned in 1. is slightly improved
Comment 10 Neil Hauge CLA 2009-09-08 19:45:42 EDT
Sorry for the delay on getting this in.  Version 3 of the patch has been committed to head.  Thanks for the contribution!