ofbiz-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mathieu Lirzin (Jira)" <j...@apache.org>
Subject [jira] [Commented] (OFBIZ-10966) JSON entity data import and export utility
Date Sun, 22 Sep 2019 11:22:00 GMT

    [ https://issues.apache.org/jira/browse/OFBIZ-10966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16935286#comment-16935286
] 

Mathieu Lirzin commented on OFBIZ-10966:
----------------------------------------

Hello Jayansh,

I have tried your patch and noticed the nice improvements you made in particular with the
addition of tests. 

When running the unit test fails on my machine I get the following error:
{code}
> Task :test

org.apache.ofbiz.entity.util.EntityJsonReaderTests > parse FAILED
    java.io.IOException at EntityJsonReaderTests.java:82
        Caused by: java.lang.reflect.InvocationTargetException at EntityJsonReaderTests.java:82
            Caused by: java.io.IOException at EntityJsonReaderTests.java:82
                Caused by: java.lang.NullPointerException at EntityJsonReaderTests.java:82
{code}

and after trying to rapidly debug, I noticed that you used Java reflection which should be
avoided because it makes things complex and brittle. There are multiple solutions to avoid
that but a flexible one is to use a map associating strings to method references.

Are you able to reproduce the unit test failure? Can you rework your code to not use reflection
?

Thanks in advance, and sorry for the long delay.

Note: I will proceed the revert of you initial version I intended to do last month.

> JSON entity data import and export utility
> ------------------------------------------
>
>                 Key: OFBIZ-10966
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10966
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>            Reporter: Jayansh Shinde
>            Assignee: Mathieu Lirzin
>            Priority: Minor
>             Fix For: Upcoming Branch
>
>         Attachments: OFBIZ-10966_27062019.patch, OFBiz-10966.patch, OFBiz-Web-Tools-JSON-Data-Export-All.png,
OFBiz-Web-Tools-JSON-Data-Import-Dir.png, exportJson.png, importJson.png
>
>
> Currently, we support import/export entity data in XML format.
>  Nowadays JSON is widely used in industry, we can have support for JSON format which
looks quite similar to XML support.
> Here is example of XML data and it's JSON version
> {code:java}
> <Party partyId="123456" partyTypeId="PERSON" statusId="PARTY_ENABLED"/>
> {code}
> {code:java}
> {“Party”: {"partyId":"123456","partyTypeId":"PERSON","statusId":"PARTY_ENABLED”}}
> {code}
>  
> *Design Proposal*
> We can write *entityImportJson* and *entityImportDirJson* services for importing JSON
from screen and directory respectively.
> And the *entityExportAllJson* service for exporting entity data in JSON.
>  
> *Import Design*
>  The import service will perform following operations:
>  1.) Validate the input JSON data (I am in process of exploring the way for this)
>  2.) On successful validation, convert JSON to OFBiz's entity model (GenericValue)
>  3.) The GenericValue will be inserted in database by some handler class for e.g we can
write JsonDataHandler, it will convert given JSON to List<GenericValue>, and finally
write it to database (Similar pattern is used in XML import).
>  
> *Export Design*
>  Based on existing XML pattern the writeXmlText method of GenericEntity class write the
exported data in XML format. 
>  In the similar way, we can implement writeJsonText to export data in JSON format.
> Please free feel to share your thought.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message