OFBiz
  1. OFBiz
  2. OFBIZ-2866

Allow entity-data-reader to indicate if it should insert, update, or upsert records

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Trunk
    • Fix Version/s: None
    • Component/s: framework
    • Labels:
      None

      Description

      This ticket is the result of forum conversation: http://www.nabble.com/Handling-one-time-seed-data-tt25136333.html

      What this support provides is the ability at the entity-data-reader level to indicate if the entities loaded from that reader should insert, update, or upsert records into the database. The current process is an upsert. This patch provides the following:

      • enhancement on entity-data-reader to indicate if "insert-values" and "update-values" is true/false. By default they are true/true; this provides the ability to re-execute "seed-initial" data to pickup new records (but leave others unmodified) by setting the attributes to true/false (effectively skipping updates). In practice these are the only two flavors, but this design provides the flexibility to do all four permutations.
      • resulting informational messages were showing the "read" total but calling this the "changed" total. A new object was created (entityDataLoadResults) which can hold any metrics related to the data load. Signature changes and some logic changes were put into place to use this result and then nicely report a true "written / read" information message during and at the end of the data load.
      • a bug was found when the dirty check in DelegatorImpl.storeAll where it was using the GenericEntity.get method for the new/old value comparison. This performed a resource lookup so these values would always match. I found this when testing my code using the GeoData – I was changing the country name and it was not being properly updated. The fix was to change the protection on the GenericEntity.getFieldValue method and then use that in the DelegatorImpl. This does a check of the true database value vs. the value form the data loading entity (typically xml file).

      There should be no changes other than the information messages coming out in both the DataLoader and the WebToolsService.entityImportReaders.

      Configuration change can be applied as such:
      <entity-data-reader name="seed-initial" insert-values="true" update-values="false"/>

      Sample of the information messages from a load:
      00005 of 00029 from file:/Users/rmorley/dev/ofbiz-trunk/ofbiz/specialpurpose/assetmaint/data/AssetMaintDemoData.xml
      ======= Finished the data load with 1086 rows changed of 12184 rows read.

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Bob Morley
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development