Derived model - name of single embedded element in set defaults to set name

Posts   
 
    
Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 31-May-2019 10:23:31   

using LLBLGen pro 5.5.1 Derived Models

When selecting a set as subelement(s) in a derived model the name of Set of elements (Kind=Field, Set of elements) defaults to the correct set name of the entity set(from the navigator name I presume), but the single embedded element in the set defaults to the same plural name, but there is a singular name of the entity, in fact the referenced entity name is singular itself. Would be really nice that it would pick that one (or create a setting for a preferred way).

Walaa avatar
Walaa
Support Team
Posts: 14982
Joined: 21-Aug-2005
# Posted on: 31-May-2019 13:25:50   

I can't reproduce it, but maybe I'm missing something. Could you please provide a screenshot?

Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 31-May-2019 17:39:52   

here it is

Attachments
Filename File size Added on Approval
llblgen derived model singular is plural.png 86,423 31-May-2019 17:40.01 Approved
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39747
Joined: 17-Aug-2003
# Posted on: 03-Jun-2019 10:12:29   

It does a singularization of the navigator, and doesn't use the entity name for an embedded element. The main reason is that if you have 2 or more navigators, all with the same type, you get weird names, while the navigator in general represents the right elements. Like you have VisitingAddresses and BillingAddresses, both of type 'Address', and you add both to the derived element, you get 'VisitingAddress' and 'BillingAddress'. Otherwise you'd get 'Address' and 'Address1' which would require a rename.

'Drukken' is Dutch and therefore the standard singularization plugin won't pick it up and will leave it alone, hence the name stays 'Drukken'. With a dutch plural/singularization plugin this would be fixed. You can adjust the one shipped with the designer btw, sourcecode is in the source archive. It's a simple list of regexp definitions. For dutch it'll be a bit of a challenge, as 'drukken' needs to become 'druk' and not 'drukk' so you can't use the 'en' suffix to '' transition for most dutch words.

Frans Bouma | Lead developer LLBLGen Pro
Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 04-Jun-2019 14:47:29   

I've never succeeded in creating such a Dutch singularization method, because of all the exceptions. When something doesnt work 100%, I depend on metadata.

I would suggest a new property somewhere in which you can enter the singular name. Best place would be in the Relationship, albeit something for Derived models specific, so that must be clear for the users, as they should not expect it for generating code in the Entity models itself.

Walaa avatar
Walaa
Support Team
Posts: 14982
Joined: 21-Aug-2005
# Posted on: 05-Jun-2019 02:13:45   

I would suggest a new property somewhere in which you can enter the singular name

You can edit the Navigator name, and since Derived Elements and Sub-Elements replies on the Navigator name, the change would be carried out to the Derived Model as well.

Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 05-Jun-2019 08:43:33   

I hate to disappoint you Walaa, but this both sets the singular as well as the plural form to the same name, so this is no solution.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39747
Joined: 17-Aug-2003
# Posted on: 05-Jun-2019 09:51:32   

If you have to enter it somewhere, why not rename the derived element name instead? that's the same amount of work.

The only thing I see which might help (but likely is overlooked 99% of the time) is a setting where you get the derived element name named after the entity it targets. (so in my example above you'd get Address and Address1). It would suck in situation where you don't want it, but it could help with languages which don't have a singularization plugin.

Frans Bouma | Lead developer LLBLGen Pro
Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 05-Jun-2019 11:15:00   

The reason is that I have about 500 Entities and just a few have corresponding Derived Models. For each module I convert from legacy code I create new Derived models, so this is done over time. An idea is to go over all entity relationships once and enter singular names (if it would be possible), then when it is time to create one or more Derived models (i'll create more from one entity when needed with smaller or bigger parts of the entity graph) I dont have to remember to fix all singular names. You can imagine selecting/deselecting properties/children as needed is easy; worrying about naming after selecting some child property is tricky, for me it is (sometimes only to see in code that I forget to singularize...). Just to have these naming set up front would have been easier. And yes, naming it after the original entity does not work good either as you already stated.

Just to let you know my use-case.

I'll keep changing it by hand.

best regards

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39747
Joined: 17-Aug-2003
# Posted on: 05-Jun-2019 12:25:39   

Ah I see what you mean now with singular name on a navigator. With that number of entities, you indeed want to have proper automation in place.

I did some research to see if someone had already created an inflector/inflection (the system originates from Ruby on Rails with its inflection system and is ported to many program languages since) for Dutch I could port, but couldn't find one. Then I looked at: http://www.dutchgrammar.com/en/?n=NounsAndArticles.08 as a thought entered my head "how hard can it be?" well.... frowning hard. (Boek -> Boeken, but Druk -> Drukken... )

It's a problem that I don't see a particular good solution for. Typing 500+ singular names on navigators is also not something one would do.

Other than writing a Dutch inflector... I'll ponder on it some more, and keep looking for a Dutch inflector, perhaps I run into one somewhere wink

Frans Bouma | Lead developer LLBLGen Pro
Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 05-Jun-2019 12:40:00   

Yeah, our dutch is nice, isnt? ;D

Well for me it's not so difficult because I already have all entities with both singular and plural names in my metadata. I can also read your source XML of metadata of the llblgen project. If there would be a new property on a navigator (or rather on a relationship), like 'SingularName' (or so) that you would use to create a singular name in the Derived Model, then all I have to do is check the type of relationship 1-n, lookup the plural name in my metadata and set/replace the SingularName with the matching singular name from my metadata. All that are not set, I can fix manually. That's a one time thing. after that I can just create new relationships when needed.

I could even imagine you could create a big List of all Relationships with names, source entity names and a Singular name, where one could edit the latter. With DevExpress it's a breeze....wink

haha, leave it for now. I'll just have to focus smile