Integrate 7 – building a component

This article will show you how to build a simple reusable component in DATPROF Integrate 7 Developer.

Required knowledge

  • Building a project
  • Using component libraries 
  • Placing a component from a library 

Which problem do I want to solve?

I want to build an action that will drop a table. The action must contain two user-options. Depending on the users input, the generated drop statement must use the Purge option or/and the Cascade Constraints option. This component must be modeled such way that it can only be placed on a table.

Building the component

A component is nothing more that a normal Integrate project that can be used within other projects. The first step is to create a normal project. In the project overview, we click the component settings to define two interfaces of the type boolean. One with the name cascadeconsBool and one with the name purgeBool. The label can be used to give a more aesthetic name to the interface. The user of the component will see this name. Add a additional description to explain the functionality.

The component is designed for is correctly configured. This will prevent that users can add this component to views or entity groups. The component code is used to prefix the name of the action when the component is placed on a specific table. When this component is placed on the CUSTOMER table, the action will be called DRP_CUSTOMER.

Currently this component will do nothing. We have to add a action to the component to let it do something. This action will generate specific code that will drop the table that the component is been placed on. Add a SQL action to the action menu and enter the sql code like the screenshot below.

You may notice the purple text <# ComponentParent.Name #>. This dynamic code will be replaced with the table name during runtime generation. The next purple line is <# IF cascadeconsBool = TRUE THEN #> CASCADE CONSTRAINTS <# END IF #>. This dynamic code will check during runtime generation if the interface is true. If so, it will generate the text, otherwise it will generate nothing.

You’ve have build your first component action. Save the project and add it to another project.

When you use this component, you will see something like this.

When the project is generated, this will generate a SQL file for the CUSTOMER and the ORDERS table with the component code. You will see that the purple lines are replaced by the table names and the options according to the user settings.

drp_customer.drop_table.sql

DROP TABLE CUSTOMER CASCADE CONSTRAINTS   PURGE  ;

drp_orders.drop_table.sql

DROP TABLE ORDERS  ;

Don't miss anything

Signup for our newsletter