cuba-platform / frontend

Monorepo for CUBA Platform Frontend Tools and Libraries
Apache License 2.0
24 stars 12 forks source link

Embedded attributes are handled incorrectly #141

Open IskandarovRost opened 4 years ago

IskandarovRost commented 4 years ago

1) Create an Embeddable entity Address with several lines 2) Create an entity "Customer" 3) Embed the Address to Customer

...
public class Customer extends StandardEntity {
    private static final long serialVersionUID = -6557138342855944171L;

    @Column(name = "GRADE")
    protected Integer grade;

    @Column(name = "NAME")
    protected String name;

    @Embedded
    @EmbeddedParameters(nullAllowed = false)
    @AttributeOverrides({
            @AttributeOverride(name = "line1", column = @Column(name = "MAIN_ADDRESS_LINE1")),
            @AttributeOverride(name = "line2", column = @Column(name = "MAIN_ADDRESS_LINE2"))
    })
    protected Address mainAddress;

    @Embedded
    @AttributeOverrides({
            @AttributeOverride(name = "line1", column = @Column(name = "DELIVERY_ADDRESS_LINE1")),
            @AttributeOverride(name = "line2", column = @Column(name = "DELIVERY_ADDRESS_LINE2"))
    })
    protected Address deliveryAddress;

4) Create a view containg all the fields of Customer and addresses image.png 5) Create React frontend client using Studio 6) Create 'Entity management' for Customer, select the view image.png 7) start the application

AR: on customer editor the controls for addresses are as like it is a link or enum; image.png

ER: Vaadin editor is generated simply with this fields on form image.png

IskandarovRost commented 4 years ago

After the fix of #36 Embedded attributes are still lookups

IskandarovRost commented 4 years ago

And could not save a new instance with embedded attribute 1) "Full entity" has embedded "Address"

public class FullEntity extends StandardEntity {
    private static final long serialVersionUID = 2052734884961142284L;

    @Embedded
    @EmbeddedParameters(nullAllowed = false)
    @AttributeOverrides({
            @AttributeOverride(name = "lineOne", column = @Column(name = "ADDRESS_LINE_ONE")),
            @AttributeOverride(name = "lineTwo", column = @Column(name = "ADDRESS_LINE_TWO")),
            @AttributeOverride(name = "postcode", column = @Column(name = "ADDRESS_POSTCODE"))
    })

    private Address address;

2) Create React module: Address.ts FullEntity.ts 3) Create Entity management 4) Create a new instance of the Full entity.

AR:

12:12:33.885 ERROR c.h.a.r.a.c.RestControllerExceptionHandler- Exception in REST controller
java.lang.RuntimeException: JsonObject was expected for property address
    at com.haulmont.cuba.core.app.importexport.EntityImportViewBuilder.buildFromJsonObject(EntityImportViewBuilder.java:78) ~[cuba-global-7.2.4.jar:7.2.4]
    at com.haulmont.cuba.core.app.importexport.EntityImportViewBuilder.buildFromJson(EntityImportViewBuilder.java:57) ~[cuba-global-7.2.4.jar:7.2.4]
    at com.haulmont.addon.restapi.api.service.EntitiesControllerManager.createEntityFromJson(EntitiesControllerManager.java:435) ~[restapi-rest-api-7.2.0.jar:na]
    at com.haulmont.addon.restapi.api.service.EntitiesControllerManager.createResponseInfoEntity(EntitiesControllerManager.java:377) ~[restapi-rest-api-7.2.0.jar:na]
    at com.haulmont.addon.restapi.api.service.EntitiesControllerManager.createEntity(EntitiesControllerManager.java:361) ~[restapi-rest-api-7.2.0.jar:na]
    at com.haulmont.addon.restapi.api.controllers.EntitiesController.createEntity(EntitiesController.java:126) ~[restapi-rest-api-7.2.0.jar:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) ~[servlet-api.jar:na]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[servlet-api.jar:na]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[catalina.jar:9.0.27]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:9.0.27]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at com.haulmont.addon.restapi.api.auth.CubaRestLastSecurityFilter.doFilter(CubaRestLastSecurityFilter.java:90) ~[restapi-rest-api-7.2.0.jar:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]