Grails 3.3.10 - DefaultGrailsDomainClass

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails 3.3.10 - DefaultGrailsDomainClass

Pedro Gentil
I am migrating my application from version 2.5.6 to version 3.3.10.
How can I declare a variable of type DefaultGrailsDomainClass?
In the current version references to the org.grails.core.DefaultGrailsDomainClass class have been deprecated ...
For exaple:

...

def mainClass = Class.forName(domainName)
def mClass = Class.forName(matchClass)

DefaultGrailsDomainClass domainClass = new DefaultGrailsDomainClass (mainClass)
DefaultGrailsDomainClass domainMatch = new DefaultGrailsDomainClass (mClass)

....

Thanks alot

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/b2710eba-a638-4aec-b0df-8cf136de4613%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3.3.10 - DefaultGrailsDomainClass

Jeff Scott Brown-4
On 5 Oct 2019, at 18:50, Pedro Gentil Soares wrote:

> I am migrating my application from version 2.5.6 to version 3.3.10.
> How can I declare a variable of type DefaultGrailsDomainClass?
> In the current version references to the
> org.grails.core.DefaultGrailsDomainClass class have been deprecated
> ...
> For exaple:
>
> ...
>
> def mainClass = Class.forName(domainName)
> def mClass    = Class.forName(matchClass)
>
> DefaultGrailsDomainClass domainClass = new DefaultGrailsDomainClass
> (mainClass)
> DefaultGrailsDomainClass domainMatch = new DefaultGrailsDomainClass
> (mClass)
>
>

Can you summarize why you are wanting to create instances of
DefaultGrailsDomainClass?  That answer may affect the recommendation.




JSB

--
Jeff Scott Brown
Partner and Practice Lead, Grails and Micronaut

Disruptive solutions for a connected world.™
http://objectcomputing.com

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/6A9F8521-5F0D-495E-96E3-64750C1D1029%40objectcomputing.com.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3.3.10 - DefaultGrailsDomainClass

Pedro Gentil
Hi Jeff,
Thank you for your prompt reply.
In my application built on Grails version 2.5.6, I use scaffolding template customizations. I created classes of services ("DomainNameDispService.groovy") for each of my domains explaining to grails how to render each screen responsible for CRUD including the various types of possible relationships between domains (1-n, n-n, ...).
For example, the method below is used to find out what class of service a particular domain is and return the value of the static variable "columnLink". Suppose we have the domain ItemCustoIniciativa:

@Transactional
class ItemCustoIniciativaDispService {

static def pHelpFiles = [:]; static Boolean doRemotePaginate = true
static Boolean hasTreeViewPresentation = false
static String columnLink = "descricao"
......

/**
* Created by PedroGentil on 03/12/2015.
*/
class TbcDomainService {
...
def static String getColumnLink (DefaultGrailsDomainClass domainClass) {

String lsRet = ""

String lsClassName = domainClass.getFullName() + "DispService"

def classDisp = Class.forName(lsClassName)

lsRet = classDisp."${'columnLink'}"

return lsRet

} // renderSearchingFields
....

In the scaffolding template "_insertInList.gsp" :

for (p in props) {

if (p.manyToMany) {
...
it << '                        <g:form>\n'

/* Campos do Formulário */

it << '<!-- <legend>Form</legend> -->\n'

colunLink = trustBC.TbcDomainService.getColumnLink(p?.getReferencedDomainClass())

it << ' <div class="span6 default-color3">\n'
it << ' <div class="control-group">\n'
it << ' <label class="control-label">&nbsp;'
it << ' <g:message code="' << colunLink.toString() << '.label" default="Buscar" locale="\${session.getAttribute(\'locale\')}"/>\n'
it << '</label><br/>\n'
...
In oter site:

for (p in props) {

if (p.isEmbedded()) {

def embeddedPropNames = pSearchingMap.get(p.getName())

def embeddedProps = p.component.properties.findAll { embeddedPropNames}

lsRet << renderEnbeddedProps (embeddedProps, domainClass) << "\n"
...
 

Thanks a lot!

Em seg, 7 de out de 2019 às 11:24, Jeff Scott Brown <[hidden email]> escreveu:
On 5 Oct 2019, at 18:50, Pedro Gentil Soares wrote:

> I am migrating my application from version 2.5.6 to version 3.3.10.
> How can I declare a variable of type DefaultGrailsDomainClass?
> In the current version references to the
> org.grails.core.DefaultGrailsDomainClass class have been deprecated
> ...
> For exaple:
>
> ...
>
> def mainClass = Class.forName(domainName)
> def mClass    = Class.forName(matchClass)
>
> DefaultGrailsDomainClass domainClass = new DefaultGrailsDomainClass
> (mainClass)
> DefaultGrailsDomainClass domainMatch = new DefaultGrailsDomainClass
> (mClass)
>
>

Can you summarize why you are wanting to create instances of
DefaultGrailsDomainClass?  That answer may affect the recommendation.




JSB

--
Jeff Scott Brown
Partner and Practice Lead, Grails and Micronaut

Disruptive solutions for a connected world.™
http://objectcomputing.com

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/6A9F8521-5F0D-495E-96E3-64750C1D1029%40objectcomputing.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAMD44zLas%3DAoceHu6QkLVcdbOcKpvMUqNJrnH8F5VPrr0PriFA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3.3.10 - DefaultGrailsDomainClass

Jeff Scott Brown-4

It still is not clear why you need to create an instance of DefaultGrailsDomainClass yourself. This whole thing could be done without referencing any of that but assuming there is some reason you want to use DefaultGrailsDomainClass you can retrieve the instance that the framework has already created for you by calling grailsApplication.getDomainClass(ItemCustoIniciativa.name).

However, it looks like the only reason you want the DefaultGrailsDomainClass is you want to ask it for the domain class’ name, which you can just get from the domain class.

I hope some of that helps.



JSB


On 8 Oct 2019, at 4:09, Pedro Gentil Soares wrote:

Hi Jeff,
Thank you for your prompt reply.
In my application built on Grails version 2.5.6, I use scaffolding template customizations. I created classes of services ("DomainNameDispService.groovy") for each of my domains explaining to grails how to render each screen responsible for CRUD including the various types of possible relationships between domains (1-n, n-n, ...).
For example, the method below is used to find out what class of service a particular domain is and return the value of the static variable "columnLink". Suppose we have the domain ItemCustoIniciativa:

@Transactional
class ItemCustoIniciativaDispService {

static def pHelpFiles = [:]; static Boolean doRemotePaginate = true
static Boolean hasTreeViewPresentation = false
static String columnLink = "descricao"
......

/**
* Created by PedroGentil on 03/12/2015.
*/
class TbcDomainService {
...
def static String getColumnLink (DefaultGrailsDomainClass domainClass) {

String lsRet = ""

String lsClassName = domainClass.getFullName() + "DispService"

def classDisp = Class.forName(lsClassName)

lsRet = classDisp."${'columnLink'}"

return lsRet

} // renderSearchingFields
....

In the scaffolding template "_insertInList.gsp" :

for (p in props) {

if (p.manyToMany) {
...
it << '                        <g:form>\n'

/* Campos do Formulário */

it << '<!-- <legend>Form</legend> -->\n'

colunLink = trustBC.TbcDomainService.getColumnLink(p?.getReferencedDomainClass())

it << ' <div class="span6 default-color3">\n'
it << ' <div class="control-group">\n'
it << ' <label class="control-label">&nbsp;'
it << ' <g:message code="' << colunLink.toString() << '.label" default="Buscar" locale="\${session.getAttribute(\'locale\')}"/>\n'
it << '</label><br/>\n'
...
In oter site:

for (p in props) {

if (p.isEmbedded()) {

def embeddedPropNames = pSearchingMap.get(p.getName())

def embeddedProps = p.component.properties.findAll { embeddedPropNames}

lsRet << renderEnbeddedProps (embeddedProps, domainClass) << "\n"
...
 

Thanks a lot!

Em seg, 7 de out de 2019 às 11:24, Jeff Scott Brown <[hidden email]> escreveu:
On 5 Oct 2019, at 18:50, Pedro Gentil Soares wrote:

> I am migrating my application from version 2.5.6 to version 3.3.10.
> How can I declare a variable of type DefaultGrailsDomainClass?
> In the current version references to the
> org.grails.core.DefaultGrailsDomainClass class have been deprecated
> ...
> For exaple:
>
> ...
>
> def mainClass = Class.forName(domainName)
> def mClass    = Class.forName(matchClass)
>
> DefaultGrailsDomainClass domainClass = new DefaultGrailsDomainClass
> (mainClass)
> DefaultGrailsDomainClass domainMatch = new DefaultGrailsDomainClass
> (mClass)
>
>

Can you summarize why you are wanting to create instances of
DefaultGrailsDomainClass?  That answer may affect the recommendation.




JSB

--
Jeff Scott Brown
Partner and Practice Lead, Grails and Micronaut

Disruptive solutions for a connected world.™
http://objectcomputing.com

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/6A9F8521-5F0D-495E-96E3-64750C1D1029%40objectcomputing.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAMD44zLas%3DAoceHu6QkLVcdbOcKpvMUqNJrnH8F5VPrr0PriFA%40mail.gmail.com.


--
Jeff Scott Brown
Partner and Practice Lead, Grails and Micronaut

Disruptive solutions for a connected world.™
http://objectcomputing.com

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/586E976A-1534-4C48-9403-45E2778B30C6%40objectcomputing.com.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3.3.10 - DefaultGrailsDomainClass

Pedro Gentil
Hi Jeff

Actually I don't want to create an element of type DefaultGrailsDomainClass. We need to access this domainClass element in various situations within the optimized scaffolding templates - as shown in the few examples I have presented. For example, the file "_insertInList.gsp" is part of the original Grails version 2.5.6 scaffolding templates.

One of my optimizations for "_insertInList.gsp" 's content is:

colunLink = trustBC.TbcDomainService.getColumnLink(p?.getReferencedDomainClass())

it << ' <div class="span6 default-color3">\n'
it << ' <div class="control-group">\n'
it << ' <label class="control-label">&nbsp;'
it << ' <g:message code="' << colunLink.toString() << '.label" default="Buscar" locale="\${session.getAttribute(\'locale\')}"/>\n'
it << '</label><br/>\n'
...

And so on.

Thanks again!




Em ter, 8 de out de 2019 às 07:25, Jeff Scott Brown <[hidden email]> escreveu:

It still is not clear why you need to create an instance of DefaultGrailsDomainClass yourself. This whole thing could be done without referencing any of that but assuming there is some reason you want to use DefaultGrailsDomainClass you can retrieve the instance that the framework has already created for you by calling grailsApplication.getDomainClass(ItemCustoIniciativa.name).

However, it looks like the only reason you want the DefaultGrailsDomainClass is you want to ask it for the domain class’ name, which you can just get from the domain class.

I hope some of that helps.



JSB


On 8 Oct 2019, at 4:09, Pedro Gentil Soares wrote:

Hi Jeff,
Thank you for your prompt reply.
In my application built on Grails version 2.5.6, I use scaffolding template customizations. I created classes of services ("DomainNameDispService.groovy") for each of my domains explaining to grails how to render each screen responsible for CRUD including the various types of possible relationships between domains (1-n, n-n, ...).
For example, the method below is used to find out what class of service a particular domain is and return the value of the static variable "columnLink". Suppose we have the domain ItemCustoIniciativa:

@Transactional
class ItemCustoIniciativaDispService {

static def pHelpFiles = [:]; static Boolean doRemotePaginate = true
static Boolean hasTreeViewPresentation = false
static String columnLink = "descricao"
......

/**
* Created by PedroGentil on 03/12/2015.
*/
class TbcDomainService {
...
def static String getColumnLink (DefaultGrailsDomainClass domainClass) {

String lsRet = ""

String lsClassName = domainClass.getFullName() + "DispService"

def classDisp = Class.forName(lsClassName)

lsRet = classDisp."${'columnLink'}"

return lsRet

} // renderSearchingFields
....

In the scaffolding template "_insertInList.gsp" :

for (p in props) {

if (p.manyToMany) {
...
it << '                        <g:form>\n'

/* Campos do Formulário */

it << '<!-- <legend>Form</legend> -->\n'

colunLink = trustBC.TbcDomainService.getColumnLink(p?.getReferencedDomainClass())

it << ' <div class="span6 default-color3">\n'
it << ' <div class="control-group">\n'
it << ' <label class="control-label">&nbsp;'
it << ' <g:message code="' << colunLink.toString() << '.label" default="Buscar" locale="\${session.getAttribute(\'locale\')}"/>\n'
it << '</label><br/>\n'
...
In oter site:

for (p in props) {

if (p.isEmbedded()) {

def embeddedPropNames = pSearchingMap.get(p.getName())

def embeddedProps = p.component.properties.findAll { embeddedPropNames}

lsRet << renderEnbeddedProps (embeddedProps, domainClass) << "\n"
...
 

Thanks a lot!

Em seg, 7 de out de 2019 às 11:24, Jeff Scott Brown <[hidden email]> escreveu:
On 5 Oct 2019, at 18:50, Pedro Gentil Soares wrote:

> I am migrating my application from version 2.5.6 to version 3.3.10.
> How can I declare a variable of type DefaultGrailsDomainClass?
> In the current version references to the
> org.grails.core.DefaultGrailsDomainClass class have been deprecated
> ...
> For exaple:
>
> ...
>
> def mainClass = Class.forName(domainName)
> def mClass    = Class.forName(matchClass)
>
> DefaultGrailsDomainClass domainClass = new DefaultGrailsDomainClass
> (mainClass)
> DefaultGrailsDomainClass domainMatch = new DefaultGrailsDomainClass
> (mClass)
>
>

Can you summarize why you are wanting to create instances of
DefaultGrailsDomainClass?  That answer may affect the recommendation.




JSB

--
Jeff Scott Brown
Partner and Practice Lead, Grails and Micronaut

Disruptive solutions for a connected world.™
http://objectcomputing.com

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/6A9F8521-5F0D-495E-96E3-64750C1D1029%40objectcomputing.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAMD44zLas%3DAoceHu6QkLVcdbOcKpvMUqNJrnH8F5VPrr0PriFA%40mail.gmail.com.


--
Jeff Scott Brown
Partner and Practice Lead, Grails and Micronaut

Disruptive solutions for a connected world.™
http://objectcomputing.com

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/586E976A-1534-4C48-9403-45E2778B30C6%40objectcomputing.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAMD44zJ%3DNnfo3UyN7y93SRr3gBMqAHYMnYA88XDMXzFdGwimYA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3.3.10 - DefaultGrailsDomainClass

Jeff Scott Brown-4
On 8 Oct 2019, at 13:46, Pedro Gentil Soares wrote:

> Hi Jeff
>
> Actually I don't want to create an element of type
> DefaultGrailsDomainClass. Your original note included the following:

Your original note included the following:

def mainClass = Class.forName(domainName)
def mClass    = Class.forName(matchClass)
DefaultGrailsDomainClass domainClass = new DefaultGrailsDomainClass
(mainClass)
DefaultGrailsDomainClass domainMatch = new DefaultGrailsDomainClass
(mClass)

That is why I thought you wanted to create instances of
DefaultGrailsDomainClass.




JSB

--
Jeff Scott Brown
Partner and Practice Lead, Grails and Micronaut

Disruptive solutions for a connected world.™
http://objectcomputing.com

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/8CEB9D3C-80CF-4E0A-8D8A-37A993A0FC1D%40objectcomputing.com.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3.3.10 - DefaultGrailsDomainClass

Pedro Gentil
In reply to this post by Pedro Gentil
Hi Jeff.
It is true. I apologize to you for not paying attention to the case.
Let's go: Since we have two class names, suppose 'org.Book' and 'org.Author' in a 1-n relationship. The idea is to be able to investigate the classes that correspond to the domains: make the classes talk about themselves, so to speak.
Thanks a lot.

Em sábado, 5 de outubro de 2019 13:50:05 UTC-3, Pedro Gentil Soares escreveu:
I am migrating my application from version 2.5.6 to version 3.3.10.
How can I declare a variable of type DefaultGrailsDomainClass?
In the current version references to the org.grails.core.DefaultGrailsDomainClass class have been deprecated ...
For exaple:

...

def mainClass = Class.forName(domainName)
def mClass = Class.forName(matchClass)

DefaultGrailsDomainClass domainClass = new DefaultGrailsDomainClass (mainClass)
DefaultGrailsDomainClass domainMatch = new DefaultGrailsDomainClass (mClass)

....

Thanks alot

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/9fc2c0fc-e946-4e5c-8922-049ba7639f58%40googlegroups.com.