Demoiselle-Nimble: Error generating CRUD Vaadin

0

I'm using the class below, Bank.java, below:

@Entity
public class Banco implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id 
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="banco_seq_gen")
    @SequenceGenerator(name = "banco_seq_gen", sequenceName = "banco_id_seq",allocationSize=1)
    private Integer id;

    @Column
    @TextField
    @Field(prompt = "{banco.prompt.numero}", label = "{banco.label.numero}")
    @NotNull(message = "{banco.numero.erro.null}")
    private String numero;

    @Column
    @TextField
    @Field(prompt = "{banco.prompt.descricao}", label = "{banco.label.description}")
    @NotNull(message = "{banco.descricao.erro.null}")
    private String descricao;

    public Banco() {
        super();    
    }

    public Banco(String numero, String descricao) {     
        this.numero = numero;
        this.descricao = descricao;
    }

    // Getters and setter omitidos!
}

And the same is giving the following error:

INFO  FROM: C:\Demoiselle\ide\eclipse-4.4.1\plugins\br.gov.frameworkdemoiselle.tools.nimble.eclipse_1.2.0\templates\generate-crud-vaadin\src\main\resources\messages_en.properties.fragment.groovy
groovy.lang.MissingMethodException: No signature of method: static br.gov.frameworkdemoiselle.tools.nimble.util.ParserUtil.getClassAttributesFromFile() is applicable for argument types: (java.lang.String) values: [C:\Demoiselle\workspace\vaadinfinance/src/main/java/br/com/djsystem/domain/Banco.java]
    at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1370)
    at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1356)
    at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:50)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at SimpleTemplateScript2.run(SimpleTemplateScript2.groovy:5)
    at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:165)
    at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:177)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:230)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at br.gov.frameworkdemoiselle.tools.nimble.template.GroovyTemplate.applyTemplate(GroovyTemplate.groovy:58)
    at br.gov.frameworkdemoiselle.tools.nimble.template.Template$applyTemplate.call(Unknown Source)
    at br.gov.frameworkdemoiselle.tools.nimble.util.TemplateUtil.applyTemplate(TemplateUtil.groovy:58)
    at br.gov.frameworkdemoiselle.tools.nimble.util.TemplateUtil$applyTemplate.call(Unknown Source)
    at br.gov.frameworkdemoiselle.tools.nimble.DemoiselleNimble$_applyTemplates_closure5.doCall(DemoiselleNimble.groovy:314)
    at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906)
    at groovy.lang.Closure.call(Closure.java:412)
    at groovy.lang.Closure.call(Closure.java:425)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:980)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:978)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:978)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:978)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:1212)
    at org.codehaus.groovy.runtime.dgm$763.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at br.gov.frameworkdemoiselle.tools.nimble.DemoiselleNimble.applyTemplates(DemoiselleNimble.groovy:293)
    at br.gov.frameworkdemoiselle.tools.nimble.DemoiselleNimble$applyTemplates.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
    at br.gov.frameworkdemoiselle.tools.nimble.gui.wizard.tools.TemplateVariablesStep2.finish(TemplateVariablesStep2.groovy:159)
    at br.gov.frameworkdemoiselle.tools.nimble.gui.wizard.tools.TemplateVariablesStep2$finish.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at br.gov.frameworkdemoiselle.tools.nimble.gui.wizard.GenericWizardFrame$_footer_closure1.doCall(GenericWizardFrame.groovy:103)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906)
    at groovy.lang.Closure.call(Closure.java:412)
    at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:51)
    at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:82)
    at com.sun.proxy.$Proxy6.actionPerformed(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Test version 2 and 3 below.

    
asked by anonymous 11.03.2015 / 18:35

1 answer

1

It really is a bug in the Vaadin generation template. But simple enough to solve. This template generates the attributes in the /src/main/resources/messages_en.properties file that is created with the Demoiselle Maven archetype for an application with Vaadin. As the name indicates is a message file to internationalize the application using the English language (_en) as an option. As it is a template, the result is not exactly a translation of quality, but only the entries of the properties that must be translated manually. Even the Portuguese language file generates entries mechanically based on the names of the attributes of the pojo class. These properties should also be corrected for better presentation. What is gained in this process is the work of creating the attributes and in the case of JSF templates to link them in the XHTML pages. Even now I realized that the Portuguese template also has a problem.

One of the goals of the Demoiselle-Nimble templates is that they are just a sample of what can be done. For it is possible and encouraged that the developer himself can customize and improve according to his needs.

Because it is an error in the template, you do not have to wait for the correction because, as I said, you can do it yourself in your environment.

I still ask you to register the bug in the project tracker: link

We can consider two-way correction:

  • 1) You are not interested in internationalizing the application, so you want to ignore this file: In this way you just delete the template files:

    C: \ Demoiselle \ ide \ eclipse-4.4.1 \ plugins \ br.gov.frameworkdemoiselle.tools.nimble.eclipse_1.2.0 \ templates \ generate-crud-vaadin \ src \ main \ resources \ messages_en.properties. fragment.groovy

    and

    C: \ Demoiselle \ ide \ eclipse-4.4.1 \ plugins \ br.gov.frameworkdemoiselle.tools.nimble.eclipse_1.2.0 \ templates \ generate-crud-vaadin \ src \ main \ resources \ messages_en.properties. fragment.groovy.conf

  • 2) You want to generate the file to internationalize the application.

To fix change the contents of the file: C: \ Demoiselle \ ide \ eclipse-4.4.1 \ plugins \ br.gov.frameworkdemoiselle.tools.nimble.eclipse_1.2.0 \ templates \ generate-crud-vaadin \ src \ main \ resources \ messages_en.properties.fragment.groovy for:

    menu.new.${bean} = ${pojo}
<%

import br.gov.frameworkdemoiselle.tools.nimble.util.ParserUtil as RU
def tmpFile = new File(beanPath+beanJavaName)
def attrList = RU.getAttributesFromClassFile(tmpFile)
   if (!attrList.isEmpty()) {
        attrList.each() { attrName, attrValue -> 
            String attrLow = attrName.toLowerCase() 
    %>
    ${bean}.label.${attrLow} = ${attrName}
    ${bean}.prompt.${attrLow} = ${pojo}'s ${attrName}
    <%
        }
    } else {
    %>
    ${bean}.label.text = Text
    ${bean}.prompt.text = ${pojo}'s Text 
    <%
}
%>

The problem with the Portuguese template is that the content is the same as the other. There is even a bug in the archetype that generates the file as it is in "English" as well. Change the C: \ Demoiselle \ ide \ eclipse-4.4.1 \ plugins \ br.gov.frameworkdemoiselle.tools.nimble.eclipse_1.2.0 \ templates \ generate-crud-vaadin \ src \ main \ resources \ messages.properties.fragment .groovy for:

    menu.new.${bean} = ${pojo}
<%

import br.gov.frameworkdemoiselle.tools.nimble.util.ParserUtil as RU
def tmpFile = new File(beanPath+beanJavaName)
def attrList = RU.getAttributesFromClassFile(tmpFile)
   if (!attrList.isEmpty()) {
        attrList.each() { attrName, attrValue -> 
            String attrLow = attrName.toLowerCase() 
    %>
    ${bean}.label.${attrLow} = ${attrName}
    ${bean}.prompt.${attrLow} = ${attrName} do ${pojo} 
    <%
        }
    } else {
    %>
    ${bean}.label.text = Texto
    ${bean}.prompt.text = Texto do ${pojo}
    <%
}
%>

With these tips, you can take a look at the other templates and if you want to make your improvements.

    
11.03.2015 / 21:16