[jira] [Updated] (OFBIZ-10966) JSON entity data import and export utility

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (OFBIZ-10966) JSON entity data import and export utility

Nicolas Malin (Jira)

     [ 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}

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*

  was:
*Entity data import/export in JSON format*

 

Currently, we have support to import/export entity data in XML format. We are required to have support for JSON format which looks quite similar to XML support. I am summarising how current data looks and how its done in current system and proposing how it should be done.

 

Just an example the existing xml data may look like:

{color:#008080}<{color}{color:#3f7f7f}Party{color} {color:#7f007f}partyId{color}{color:#3c3c3c}={color}{color:#2a00ff}_"_{color}{color:#2a00ff}_123456_{color}{color:#2a00ff}_"_{color} {color:#7f007f}partyTypeId{color}{color:#3c3c3c}={color}{color:#2a00ff}_"PERSON"_{color} {color:#7f007f}statusId{color}{color:#3c3c3c}={color}{color:#2a00ff}_"PARTY_ENABLED"_{color}{color:#008080}/>{color}

same proposed JSON data will look like:

 

{color:#000000}_{“Party”: \{"partyId":"123456","partyTypeId":"PERSON","statusId":"PARTY_ENABLED”}}_{color}

 

{color:#000000}*Proposal:*{color}

_Services can be *entityImportJson* and *entityImportDirJson* for importing json from screen and directory respectively. And *entityExportAllJson* for exporting entity data in JSON, similar to existing services for xml. {color:#000000}My suggestion that Json data must be validated via a json schema during upload.{color}{color:#000000}R{color}{color:#000000}efer {color}{color:#000000}[https://json-schema.org/] {color}{color:#000000}for more information on json schema.{color}_


> 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}
> 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*



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)