BPA State level changes
Introduction
This document will help you to move any Master/Entity to state level. Basically moving one master to state level means master data will be stored in “state” schema and access by all other city schema's.
Changes
Add schema attribute to @Table annotation in the master entity file .
Ex: @Table(name = "eg_user", schema = "state")
Add schema attribute to @SequenceGenerator annotation in the master entity file.
Ex: @SequenceGenerator(name = User.SEQ_USER, sequenceName = User.SEQ_USER, allocationSize = 1, schema = "state")
Drop dependant constants on master table and drop sequence and master table like below.
Ex: ALTER TABLE eg_systemuser DROP CONSTRAINT fk_systemuser_user;
ALTER TABLE eg_userrole DROP CONSTRAINT fk_user_userrole;
DROP TABLE eg_user;
DROP SEQUENCE seq_eg_user;
Re-Create master table and sequence in state schema.
Ex: CREATE TABLE IF NOT EXISTS state.eg_user
(
id bigint NOT NULL,
…….
);
CREATE SEQUENCE IF NOT EXISTS state.seq_eg_user
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
Add back the deleted constants on master table from other dependent tables.
Ex:
ALTER TABLE eg_systemuser ADD CONSTRAINT fk_systemuser_user FOREIGN KEY (id) REFERENCES state.eg_user(id);
ALTER TABLE eg_userdevice ADD CONSTRAINT fk_user_userdevice FOREIGN KEY (userid) REFERENCES state.eg_user(id);
Prepare setup/initial/sample data for state level master like below.
INSERT INTO state.eg_user (id, username ,…..) select 1, 'egovernments' ,……. where not exists(select * from state.eg_user where username='egovernments');
Note: We have added where not exists condition in above script to skip or don't try to create same data again in state schema while adding new city(schema).
Re-Check or validate create/update/search master data is creating and getting data from state schema or not.
If we are giving option to create/update master data from city level, then we have to add tenantId to master table and persist the tenant data. This will help to retrieve data by city.
Impact on citizen, employee and stakeholder registration
While registering stakeholder in the system by default we are saving stakeholder information in “state” schema, so stakeholder can login to any city and state with same login credentials.
Employee creation we allowing in state and city level also. Employee will created in system for the tenantid from where(city/state) we are creating .
ex: If we are creating employee from Jupiter city then employee will be created with jupiter tenantid in the system , and employee can able to login only in Jupiter.
Citizen will be created in state always while creating BPA application, otherwise we are creating citizen will be created in system for the tenantid from where(city/state) we are creating.
If citizen is created in “state” schema means then he can login into any city and state with same login credentials.