FME Version
Introduction
You’ve already been loading data into different alternatives or versions of the Smallworld Cambridge database using the Smallworld writer. In the previous sections, you updated the Cambridge electricity network.
The GE Smallworld reader can also read data from different alternatives, just set the Alternative parameter on the Smallworld reader in the workbench Navigator. In addition, to reading all the selected objects from an alternative, or you can configure the reader to return only the deltas (changes) between alternatives (and/or checkpoints). This is very useful if you want to synchronize your Smallworld VMDS with another database and only export the incremental changes.
The following example requires that the updates from the Database Operations in Smallworld article have been loaded successfully into your Smallworld database. If that didn’t work, you can use the |FME alternative that was pre-configured with the changes
Step-by-step Instructions
Extract Deltas from an Alternative
After the electrical network updates have been made to a Smallworld alternative, you can examine just the differences (deltas) between the baseline and the alternative. This example will export those differences for inspection.
1. Add Smallworld Reader
Open FME Workbench. Start with a Blank workspace on the Main tab of FME Workbench.
Add this reader:
Reader Format: | Smallworld 4/5 |
Reader Dataset: | localhost:30000 |
Reader Cood. System: | OSGB-GPS-2015 |
Parameters > Service: | FMENOFACTORY |
Parameters > Table List: |
|
Uncheck "Use Search Envelope" in the Smallworld 4/5 Parameters dialog.
2. Connect Inspectors
Connect an Inspector transformer to each reader feature type.
3. Run and Inspect
Run the workspace. You’ll see all the objects from the ***top*** alternative. You won’t see any of the changes you made to the database in the previous exercise.
4. Select an Alternative
In the workspace Navigator, under the Smallworld reader, select Alternative and set:
- Alternative: |fme_updates
5. Run and Inspect
Run the workspace. You’ll see all the objects from the ‘fme_updates’ alternative. You should see the electric network, including the changes you made to the database in the previous exercise.
6. Export Changes
Back in the workspace Navigator, under the Smallworld reader, select set the following reader parameters:
Export Changes from Baseline: | Yes |
Baseline Alternative: | | |
Note the '|' or pipe character represents the ***top*** alternative.
or you can use:
Export Changes from Baseline: | Yes |
Baseline Alternative: | |fme_updates |
Checkpoint: | begin |
The 'begin' checkpoint was the first checkpoint in the |fme_updates alternative before any changes were added.
7. Run and Inspect
Run the workspace. You’ll see only the deltas between the ‘***top***’ alternative and the ‘|fme_updates’ alternative.
Note: that the Smallworld reader automatically adds and sets the fme_db_operation attribute when you export changes so you could use these features to update other databases that FME supports.
8. Save Workspace
Save the workspace: smallworld7-complete.fmw
Exporting incremental changes in this way can be used to synchronize a Smallworld VMDS with an Oracle or SQL Server or Esri Geodatabase.
Sync Smallworld with another database
The Smallworld reader allows you to extract differences between alternatives and checkpoints. The reader also set the 'fme_db_operation' attribute to the appropriate value: INSERT, UPDATE, DELETE. This makes it relatively straight forward to write to other databases and only add the changes - incremental updates. For more on using 'fme_db_operation' for incremental updates see the Tutorial: Updating Databases. Below are two example workspaces : the first 'seeds' the database, the second extracts the differences from Smallworld and uses fme_db_operation to update the target database. These should help you understand the incremental update process.
1loadpostgis.fmw
2updatepostgis.fmw
Advanced Task—WHERE Predicate
The Smallworld reader supports WHERE predicates that can be used to select a subset of data.
In the Workbench Navigator pane, locate the parameters for the Smallworld reader.
Set these parameters to select only cables whose status is "Accepted":
WHERE Clause: [Electricity] cable where Status = "Accepted"
Export Changes from Baseline: No
Run the workspace. Inspect the output. Only the ‘Accepted’ cables are exported.
Summary
This article illustrates how you can extract deltas from your Smallworld database by comparing the current alternative with a baseline alternative or checkpoint. This automatically sets the fme_db_operation attribute and would allow you to synchronize your Smallworld VMDS with another database. For more on using fme_db_operation see the article Updating Databases.
You've also seen how to include a simple WHERE predicate on your Smallworld reader.
Comments
0 comments
Please sign in to leave a comment.