Ticket #314 (new enhancement)

Opened 3 years ago

Last modified 3 years ago

change all entity Class fields into String fields

Reported by: business@… Owned by: business@…
Priority: major Milestone: Could have
Component: Unknown Version: 0.6.3
Keywords: Cc: work@…
Product: Operating system:
URL: Hardware:

Description

I saw that  http://jira.codehaus.org/browse/GRAILS-6020 was rejected as won't fix. This means that we cannot use name(unique:entity?) in TemplateField? in gdt, which means that we have no easy way of enforcing unique template names per entity in the data model. The user can potentially be confused by allowing different templates with the same name.

The only way out I see here is to change our definition of 'Class entity' in Template and TemplateField? into 'String entity'. All code that uses the entity (e.g. in the Bootstrap) should then be changed accordingly. E.g. in BootstrapTemplates?:

		def genderField = new TemplateField(
			name: 'Gender',type: TemplateFieldType.STRINGLIST, entity: Subject.class.canonicalName,
			listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female'),new TemplateFieldListItem(name: 'Unknown')])
		.with { if (!validate()) { errors.each { println it} } else save()}

So .class.canonicalName should be used instead of just 'Subject'.

Filing this as a future ticket for now, but what is your opinion on this Jeroen?

Attachments

BootStrapTemplates.groovy Download (28.5 KB) - added by business@… 3 years ago.
For testing purposes, here is a version of BootstrapTemplates? that uses the proposed change. It would of course be better to refactor this a bit and store the class names in variables.

Change History

Changed 3 years ago by business@…

As far as I know, this change would not change the data model, which already contains entity as a string field:

gscf-test=# \d template
             Table "public.template"
   Column    |          Type          | Modifiers 
-------------+------------------------+-----------
 id          | bigint                 | not null
 version     | bigint                 | not null
 description | character varying(255) | 
 entity      | character varying(255) | not null
 name        | character varying(255) | not null
 owner_id    | bigint                 | 
Indexes:
    "template_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "fkb13acc7ace213b3b" FOREIGN KEY (owner_id) REFERENCES sec_user(id)

Changed 3 years ago by business@…

For testing purposes, here is a version of BootstrapTemplates? that uses the proposed change. It would of course be better to refactor this a bit and store the class names in variables.

Changed 3 years ago by work@…

also see #406

Note: See TracTickets for help on using tickets.