[
https://issues.jboss.org/browse/FORGE-486?page=com.atlassian.jira.plugin....
]
Richard Kennard edited comment on FORGE-486 at 3/1/12 5:55 PM:
---------------------------------------------------------------
I don't know whether JavaEnum should implement MethodHolder. It's kind of moot
because Metawidget shouldn't be recursing into an Enum in the first place. It should
stop when it sees an Enum and render it as a dropdown.
Can you help me formulate a test case? I tried adding this to FacesScaffoldTest.java...
{{monospaced}} @Test
public void testGenerateEntityWithEnum() throws Exception
{
Project project = setupScaffoldProject();
queueInputLines("");
getShell().execute("java new-enum-type --package com.test.model \"public
enum RatingEnum{}\"");
getShell().execute("java new-enum-const \"1_STAR\"");
getShell().execute("java new-enum-const \"2_STAR\"");
getShell().execute("java new-enum-const \"3_STAR\"");
getShell().execute("entity --named Customer");
getShell().execute("field string --named firstName");
getShell().execute("field string --named lastName");
queueInputLines("com.test.model.RatingEnum");
getShell().execute("field custom --named rating");{{monospaced}}
But I get 'No such command java'?
was (Author: kennardconsulting):
I don't know whether JavaEnum should implement MethodHolder. It's kind of moot
because Metawidget shouldn't be recursing into an Enum in the first place. It should
stop when it sees an Enum and render it as a dropdown.
Can you help me formulate a test case? I tried adding this to FacesScaffoldTest.java...
@Test
public void testGenerateEntityWithEnum() throws Exception
{
Project project = setupScaffoldProject();
queueInputLines("");
getShell().execute("java new-enum-type --package com.test.model \"public
enum RatingEnum{}\"");
getShell().execute("java new-enum-const \"1_STAR\"");
getShell().execute("java new-enum-const \"2_STAR\"");
getShell().execute("java new-enum-const \"3_STAR\"");
getShell().execute("entity --named Customer");
getShell().execute("field string --named firstName");
getShell().execute("field string --named lastName");
queueInputLines("com.test.model.RatingEnum");
getShell().execute("field custom --named rating");
But I get 'No such command java'?
Scaffolding an entity with an enum fails
----------------------------------------
Key: FORGE-486
URL:
https://issues.jboss.org/browse/FORGE-486
Project: Forge
Issue Type: Bug
Components: Scaffold
Affects Versions: 1.0.0.Final
Reporter: Pete Muir
Priority: Critical
for
{code}
@Entity
@JsonIgnoreProperties("content")
public class MediaItem implements Serializable {
private static final long serialVersionUID = -3190368407410663590L;
@Id
@GeneratedValue(strategy=IDENTITY)
private Long id;
@Enumerated(STRING)
private MediaType mediaType;
@URL
private String url;
public Long getId() {
return id;
}
public MediaType getMediaType() {
return mediaType;
}
public void setMediaType(MediaType mediaType) {
this.mediaType = mediaType;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MediaItem mediaItem = (MediaItem) o;
if (id != null ? !id.equals(mediaItem.id) : mediaItem.id != null) return false;
return true;
}
@Override
public int hashCode() {
return id != null ? id.hashCode() : 0;
}
}
{code}
{code}
public enum MediaType {
IMAGE("Image", true);
private MediaType(String description, boolean cacheable) {
this.description = description;
this.cacheable = cacheable;
}
private final String description;
private final boolean cacheable;
public String getDescription() {
return description;
}
public boolean isCacheable() {
return cacheable;
}
}
{code}
I get
{code}
[ticket-monster] ticket-monster-1 $ scaffold from-entity
org.jboss.jdf.example.ticketmonster.model.MediaItem;
Wrote
/Users/pmuir/workspace/ticket-monster-1/src/main/java/org/jboss/jdf/examples/view/MediaItemBean.java
***ERROR*** [scaffold from-entity] Error generating default scaffolding:
java.lang.ClassCastException: org.jboss.forge.parser.java.impl.JavaEnumImpl cannot be cast
to org.jboss.forge.parser.java.MethodHolder
org.jboss.forge.shell.exceptions.CommandExecutionException: Error generating default
scaffolding: java.lang.ClassCastException: org.jboss.forge.parser.java.impl.JavaEnumImpl
cannot be cast to org.jboss.forge.parser.java.MethodHolder
at org.jboss.forge.shell.command.Execution.perform(Execution.java:153)
at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:125)
at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:63)
at org.jboss.forge.shell.ShellImpl$ExecutorThread.run(ShellImpl.java:829)
at org.jboss.forge.shell.ShellImpl.execute(ShellImpl.java:852)
at org.jboss.forge.shell.ShellImpl.doShell(ShellImpl.java:642)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
at
org.jboss.forge.shell.ShellImpl$Proxy$_$$_WeldClientProxy.doShell(ShellImpl$Proxy$_$$_WeldClientProxy.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
at
org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
at
org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
at
org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234)
at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:635)
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:622)
at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:616)
at org.jboss.forge.shell.Bootstrap$1.run(Bootstrap.java:120)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor59.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.forge.shell.command.Execution.perform(Execution.java:149)
... 31 more
Caused by: java.lang.RuntimeException: Error generating default scaffolding:
java.lang.ClassCastException: org.jboss.forge.parser.java.impl.JavaEnumImpl cannot be cast
to org.jboss.forge.parser.java.MethodHolder
at
org.jboss.forge.scaffold.faces.FacesScaffold.generateFromEntity(FacesScaffold.java:339)
at
org.jboss.forge.scaffold.plugins.ScaffoldPlugin.generateFromEntity(ScaffoldPlugin.java:174)
... 35 more
Caused by: org.metawidget.inspector.iface.InspectorException:
java.lang.ClassCastException: org.jboss.forge.parser.java.impl.JavaEnumImpl cannot be cast
to org.jboss.forge.parser.java.MethodHolder
at
org.metawidget.inspector.iface.InspectorException.newException(InspectorException.java:51)
at
org.jboss.forge.scaffold.faces.metawidget.inspector.propertystyle.ForgePropertyStyle.inspectProperties(ForgePropertyStyle.java:159)
at
org.metawidget.inspector.impl.propertystyle.BasePropertyStyle.getUncachedTraits(BasePropertyStyle.java:172)
at org.metawidget.inspector.impl.BaseTraitStyle.getTraits(BaseTraitStyle.java:126)
at
org.metawidget.inspector.impl.propertystyle.BasePropertyStyle.getProperties(BasePropertyStyle.java:54)
at
org.metawidget.inspector.impl.BaseObjectInspector.getProperties(BaseObjectInspector.java:499)
at
org.metawidget.inspector.impl.BaseObjectInspector.inspectTraits(BaseObjectInspector.java:341)
at
org.metawidget.inspector.impl.BaseObjectInspector.inspectAsDom(BaseObjectInspector.java:243)
at
org.metawidget.inspector.impl.BaseObjectInspector.inspectAsDom(BaseObjectInspector.java:69)
at
org.metawidget.inspector.composite.CompositeInspector.runInspector(CompositeInspector.java:241)
at
org.metawidget.inspector.composite.CompositeInspector.runInspectors(CompositeInspector.java:220)
at
org.metawidget.inspector.composite.CompositeInspector.inspectAsDom(CompositeInspector.java:167)
at
org.metawidget.inspector.composite.CompositeInspector.inspectAsDom(CompositeInspector.java:151)
at
org.metawidget.inspector.composite.CompositeInspector.inspectAsDom(CompositeInspector.java:53)
at org.metawidget.pipeline.base.BasePipeline.inspectAsDom(BasePipeline.java:344)
at org.metawidget.statically.StaticMetawidget.inspect(StaticMetawidget.java:301)
at org.metawidget.statically.StaticMetawidget.write(StaticMetawidget.java:247)
at org.metawidget.statically.StaticMetawidget.write(StaticMetawidget.java:233)
at org.metawidget.statically.BaseStaticWidget.write(BaseStaticWidget.java:126)
at org.metawidget.statically.BaseStaticXmlWidget.write(BaseStaticXmlWidget.java:168)
at org.metawidget.statically.BaseStaticWidget.write(BaseStaticWidget.java:126)
at org.metawidget.statically.StaticMetawidget.write(StaticMetawidget.java:255)
at
org.jboss.forge.scaffold.faces.FacesScaffold.writeEntityMetawidget(FacesScaffold.java:777)
at
org.jboss.forge.scaffold.faces.FacesScaffold.generateFromEntity(FacesScaffold.java:292)
... 36 more
Caused by: java.lang.ClassCastException: org.jboss.forge.parser.java.impl.JavaEnumImpl
cannot be cast to org.jboss.forge.parser.java.MethodHolder
at
org.jboss.forge.scaffold.faces.metawidget.inspector.propertystyle.ForgePropertyStyle.inspectProperties(ForgePropertyStyle.java:152)
... 58 more
[ticket-monster] ticket-monster-1 $
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira