. . .

Using other modules

Like using libraries in programming, you can use other modules within an own module.

Each module has a field containing all used modules, based on the system; its name is usedModules. Under some circumstances, the map of used modules of a module is automatically updated; an example would be setting a field type to a class of another module in class editor (attribute X in class A of module P is of type B, which is a class of module Q) or setting a inheritance from a class A to a class B of another module. But you can also set one module to be used by another manually; the latter case would make sense if the used module contains some methods or REST interfaces which should be used in an other module.

The dashboard will show all used modules in the left menu.

Setting a used module relationship manually via REST

Defining the used modules for an own module can be done via REST or in NativeModule code.

To declare used modules via REST, the using module must already exist.
Since ApiOmat 3.3 this REST end point is versioned and can be used as follows:


cURL

curl -X POST BASE_URL/yambas/rest/modules/MODULENAME/v/MODULEVERSION/parent -d "parentModuleName=<NAME_OF_USEDMODULE>&parentModuleVersion=<VERSION_OF_USEDMODULE>" -u AUTH


This will add the module NAME_OF_USED_MODULE with version VERSION_OF_USEDMODULE in live system to a module MODULENAME in version MODULEVERSION.


Setting a used module relationship code first via NativeModule

To set the map of used modules via NativeModule code you have to differ between two module types you want to set as used modules.

  • Static modules (Basics, Push, CSV, ...) that are provided by ApiOmat Yambas need to be set via @Module annotation within the module class :

    Java

    @Module( usedModules = { "Basics" } )

    After the used module relation to the needed static modules is set you need to upload your module to your ApiOmat instance (see Upload, Update, Use). After uploading the module, the used module field will get updated on server and the downloaded NativeModule code will contain the used module in its lib directory as jar file.

  • Native modules (own modules) need to be set via native-module-maven plugin task called addDependency. Execute the following command from your native module project directory containing the pom.xml: Bash

    Bash
    mvn nm:addDependency -DcustomerName=<customerName> -DcustomerPassword=<customerPasswors> -Dhost=https://your.apiomat.com -DusedModuleName=<NAME_OF_USED_MODULE> -DusedModuleVersion=<VERSION_OF_USEDMODULE>

    After that the pom.xml of your module should have the needed used module dependency. Also the needed libraries should now be included in your module project.

    More information about the native-module-maven plugin can be found in the README.md of https://github.com/ApinautenGmbH/nm-maven-plugin