# Overriding the default behavior of the update functionality

By default, Oracle Endeca Workbench uses an EAC script to update MDEX Engines with new configuration each time the Save Changes button is pressed. With the preview Dgraph deployment approach, the default functionality would update each production Dgraph in addition to the preview Dgraph. There are two ways to override this default behavior.

- A script may be provisioned with a reserved name, instructing Oracle Endeca Workbench to execute the custom script rather than using its default update script. The following configuration excerpt demonstrates how this script might be implemented.

      <script id="EndecaMDEXUpdateScript">
        <log-dir>./logs</log-dir>
        <provisioned-script-command>
          ./control/runcommand.bat EndecaMDEXUpdateScript
        </provisioned-script-command>
        <bean-shell-script>
          <![CDATA[
        log.info("Applying config to Web Studio preview dgraph.");

        // don't filter, apply all rules to preview dgraph
        filterInactiveRules = false;

        // download MDEX config from Web Studio to
        // preview dgraph's input directory
        getWsDgraphFiles = new GetWSDgraphFilesUtility(WSDgraph.getAppName(),
          WSDgraph.getEacHost(), WSDgraph.getEacPort(),
          WSDgraph.isSslEnabled(), WSDgraph.getDataPrefix());
        getWsDgraphFiles.init(WSDgraph.getHostId(), ConfigManager.getWsHost(),
          ConfigManager.getWsPort(), WSDgraph.getInputDir(),
          filterInactiveRules, WSDgraph.getWorkingDir());
        getWsDgraphFiles.run();

        // trigger config update (and cache flush) in preview dgraph
        WSDgraph.callDgraphConfigUpdateUrl();

        log.info("Web Studio preview dgraph updated.");
          ]]>
        </bean-shell-script>
      </script>

  Note that this script has the ID "`EndecaMDEXUpdateScript`." This is the reserved script name that must be used when provisioning the script, to ensure that Oracle Endeca Workbench recognizes and invokes the script when saving configuration changes.
  1. In addition, note that the script updates a Dgraph named `WSDgraph`, which can be configured as follows:

         <dgraph id="WSDgraph" host-id="ITLHost" port="1">
           <properties>
             <property name="restartGroup" value="WebStudio" />
           </properties>
           <log-dir>./logs/dgraphs/WSDgraph</log-dir>
           <input-dir>./data/dgraphs/WSDgraph/dgraph_input</input-dir>
           <update-dir>./data/dgraphs/WSDgraph/dgraph_input/updates</update-dir>
           <app-config-dir>./data/dgraphs/WSDgraph/dgraph_input</app-config-dir>
         </dgraph>

  2. The new Dgraph should also be added to the `DgraphCluster`, so that it is updated along with other Dgraphs during baseline and partial updates.

         <dgraph-cluster id="DgraphCluster" getDataInParallel="true">
           <dgraph ref="WSDgraph" />
           <dgraph ref="Dgraph1" />
           <dgraph ref="Dgraph2" />
         </dgraph-cluster>

  Once these changes have been made, the environment has a Dgraph dedicated to Workbench preview and uses the BaselineUpdate, PartialUpdate, and ConfigUpdate script to apply changes saved in the Workbench to the production Dgraphs.
  Note: Oracle Endeca Workbench's dynamic business rule preview functionality always selects the first Dgraph provisioned for the application to test which business rules have fired. In order to have this select the dedicated Oracle Endeca Workbench preview Dgraph, the WSDgraph should be specified first in the AppConfig.xml file definition of the `DgraphCluster`. This ensures that, when provisioning the cluster, the Workbench Dgraph is added first, and is selected by the Workbench to determine status messages when previewing rules.
- By provisioning one or more Dgraphs with a pre-defined set of properties, Oracle Endeca Workbench can be instructed to perform its default update operation on that subset of Dgraphs. To configure a `WSDgraph` as described above, start by configuring all other Dgraphs not to be updated by Oracle Endeca Workbench. This can be done by setting the property "`WebStudioSkipConfigUpdate`" in the `DgraphDefaults`:

        <dgraph-defaults>
          <properties>
      ...
            <property name="WebStudioSkipConfigUpdate" value="true" />
          </properties>
      ...
        </dgraph-defaults>

  Note that this property can also be set individually for each Dgraph, rather than in the defaults. Once set, the property must be set to “`false`” for the `WSDgraph`, to ensure it is updated by the Oracle Endeca Workbench. In addition, another property, “`WebStudioMDEX`” should be set on the `WSDgraph` to indicate to Oracle Endeca Workbench that this is the Dgraph to use when previewing the rules that have been triggered.

      <dgraph id="WSDgraph" host-id="ITLHost" port="1">
        <properties>
          <property name="restartGroup" value="WebStudio" />
          <property name="WebStudioSkipConfigUpdate" value="false" />
          <property name="WebStudioMDEX" value="true" />
        </properties>
        <log-dir>./logs/dgraphs/WSDgraph</log-dir>
        <input-dir>./data/dgraphs/WSDgraph/dgraph_input</input-dir>
        <update-dir>./data/dgraphs/WSDgraph/dgraph_input/updates</update-dir>
        <app-config-dir>./data/dgraphs/WSDgraph/dgraph_input</app-config-dir>
      </dgraph>

  For details about these properties, refer to the Oracle Endeca Workbench Administrator's Guide.

There are two implications to deploying either of these approaches that should be considered.

- When using the first approach, the custom EndecaMDEXUpdateScript implementation will take longer to execute than default Workbench implementation. The script described above is simple and executes relatively quickly, but cannot execute as quickly as native Workbench code. Business users should expect a brief delay when saving changes in Oracle Endeca Workbench. For this reason, the second approach (configuring the default Oracle Endeca Workbench script) may be a better choice.
- For both approaches, the preview Dgraph's index is updated simultaneously with the production Dgraph cluster. This means that Oracle Endeca Workbench changes that require a baseline update to apply are not previewed, but are immediately applied to production. This includes changes to stop word configuration.

Related concepts
Oracle Endeca Workbench deployed with a preview Dgraph