[ 
https://issues.apache.org/jira/browse/OFBIZ-10966?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jayansh Shinde updated OFBIZ-10966:
-----------------------------------
    Description: 
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.

  was:
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}

will look like this in JSON format

{code:json}
{“Party”: 
{"partyId":"123456","partyTypeId":"PERSON","statusId":"PARTY_ENABLED”}}
{code}
Here is design proposal

We can write entityImportJson and entityImportDirJson services for importing 
JSON from screen and directory respectively. And entityExportAllJson for 
exporting entity data in XML.

*Import Design*
We may validate the JSON schema during upload (I am in process of exploring it)

The import service will read the JSON data, validate it, then convert it to 
OFBiz's entity data model (GenericEntity) and finally commit to database using 
some handler class.
Like, we can write JsonDataHandler, this convert given JSON data to 
List<GenericValue> and write it to database.
{code:java}
private void writeValues(List<GenericValue> valuesToWrite) throws 
GenericEntityException {
    if (this.checkDataOnly) {
        EntityDataAssert.checkValueList(valuesToWrite, delegator, 
this.getMessageList());
    } else {
        delegator.storeAll(valuesToWrite, new 
EntityStoreOptions(createDummyFks));
    }
}
{code}

*Export Design*


> 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
>            Priority: Minor
>
> 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
(v7.6.3#76005)

Reply via email to