Application components - executing components from Main app

When I develop payroll, accounts, sales, inventory modules as component of my ERP system, I understand they are individual projects having component descriptor created. As a result, those components will have their respective log-in option. If I want to bring all or some of those modules under one main application, say myERP, then how can I deal with:

  1. Use only one log-in, inside the main application myERP and bypass individual modules log-in
  2. Run those modules (components) from the main app myERP?

The example of the main screen may look like something as attached after the log-in.

Any ideas by anyone?

main menu

Hi Mortoza,

The application components are needed to create reusable parts of applications. They are like full-stack libraries - you can create some project, say “Customer Management” with entities, services and UI screens, and then make it a component available for use in other applications. CUBA premium add-ons are the examples of components, just providing more generic and low-level functionality. Components must be included to the application on the development or building stage, so at runtime the application together with its components is actually a monolith.

So if you want to run separate applications with a single entry point and single-sign-on, you actually don’t need components. Of course you can still use components inside the applications, but it’s a different story. If you really want to organize your system as a set of separate applications, you actually need a single-sign-on between CUBA applications. And this ability is also comes in the platform version 6.3 - it’s just not documented yet. So in your case you will have a main application which is an entry point and perfroms user login, and a set of functional applications that will be available from the main screen of the main applications without separate login.

We will let you know when the documentation on CUBA SSO is ready.

Thank you Konstantin for the details, that is exactly what I was looking for which is coming in 6.3 version. Let me briefly explain what I am looking for in case it helps in setting an example when you are documenting.

I start with your example as starting point. Customer Management is a component where it will have everything to work as application e.g. entities, controller, screens, services etc. There will be several other components e.g. Inventory Management, Accounting, Payroll management , Accounts Receivable etc.

Situation 1:
Those components are almost independent except some touch points, Sales in Customer management will use the entities in Inventory Management, Invoice will have link with Accounts Receivable and Accounting etc. Therefore, in this case, there will be an use of Entities of Accounts Receivable in Customer Management and vice versa.

Situation 2:
In this case the standard components are extended to meet specific industry specificity. Let’s take an example to simplify. Sales Order entity is extended to two different industry category say, Make to Stock type of business and Engineer to Order types. The standard component will have standard cross industry attribute of a sales order that is common to all industries and when there is a need of specific industry, the entity, controller, screen etc. will be extended. I understand from the answer to my other question that extending screen is not possible in the studio. I’m not sure if you have any plan to include it in 6.3, if yes that will be great! If not now, documentation with a practical sample app will be helpful.

I am eagerly waiting to read and use the documentation to proceed with this approach in my development. In case you need any help in sample application featuring this, let me know (you can e-mail me).

Important question is whether do you want to use a single database for the whole system or each application will work with its own database?

As for extending screens - it works for screens located in components, so it perfectly suits your situation 2 with customizing base functionality.

Most likely single database but good thing is, now CUBA supports multiple databases.

Extending screens from components sounds amazing! When are you going to release the final version?

Please keep in mind that working with multiple databases is way more complex and unreliable than with a single. Moreover, when using single database, you probably don’t need separate applications - you can just use application components on development stage and build a monolith at the end. In my opinion, this is the most sensible approach if you don’t need to scale for millions of users.

As for the final release 6.3, I hope it will be in the middle of October.

While I am trying to use this functionality, I am getting the following exceptions at the time of running it


00:45:18.849] Updating database jdbc:postgresql://localhost/myems
:myteam-core:assembleDbScripts UP-TO-DATE
:myteam-core:updateDb
Script 50-myemsacct/init/postgres/10.create-db.sql has not been applied, running init scripts
Executing SQL script: /Users/Mortoza/studio-projects/ems/myemsteam/modules/core/build/db/50-myemsacct/init/postgres/10.create-db.sql
Failed to execute: -- begin MYEMSACCT_COMPANY
create table MYEMSACCT_COMPANY (
    ID uuid,
    VERSION integer not null,
    CREATE_TS timestamp,
    CREATED_BY varchar(50),
    UPDATE_TS timestamp,
    UPDATED_BY varchar(50),
    DELETE_TS timestamp,
    DELETED_BY varchar(50),
    --
    COMP_ID varchar(10),
    COMP_NAME varchar(255),
    BASE_CURRENCY_ID uuid,
    --
    primary key (ID)
) because: ERROR: relation "myemsacct_company" already exists
Failed to execute: insert into SYS_DB_CHANGELOG (SCRIPT_NAME, IS_INIT) values (?, ?) because: ERROR: duplicate key value violates unique constraint "sys_db_changelog_pkey"
  Detail: Key (script_name)=(50-myemsacct/update/postgres/16/160925-1-createCompany.sql) already exists.
:myteam-core:updateDb FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myteam-core:updateDb'.
> org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "sys_db_changelog_pkey"
    Detail: Key (script_name)=(50-myemsacct/update/postgres/16/160925-1-createCompany.sql) already exists.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.946 secs
[00:45:20.085] Task 'updateDb' failed
org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "sys_db_changelog_pkey"
  Detail: Key (script_name)=(50-myemsacct/update/postgres/16/160925-1-createCompany.sql) already exists.

I have manually checked but found the table only once. Thanks for your hints where the problem could be…

More info.
I am getting this exception in another app component when trying to run where the above database table does not exist.

Hi Mortoza,

Try to clean, assemble, re-generate app-component.xml, then re-install all components. If it doesn’t help, give us more information on your components and what they contain.

Hi Konstantin
I have done what you have advised but the same! and this issue is now appearing as a little bit different issue as posted in a separate thread below when I have given further update.

https://www.cuba-platform.com/discuss/t/application-components-exception-in-gradle-for-referred-component