Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Server configuration in the sormas.properties file

...

Code Block
DO $$
DECLARE 
	_roleEnabled boolean := false;
	_roleId bigint;
	_uuid varchar;
	_userRole varchar;
	_userRoles varchar[] := array['USER_ROLE_NAME_A', 'USER_ROLE_NAME_B'];
BEGIN

	FOREACH _userRole IN ARRAY _userRoles
	LOOP

		SELECT id FROM userrolesconfig WHERE userrole = _userRole INTO _roleId;
		
		IF(_roleId is null) 
			THEN 
				_uuid = overlay(overlay(overlay(
                            substring(upper(REPLACE(CAST(CAST(md5(CAST(random() AS text) || CAST(clock_timestamp() AS text)) AS uuid) AS text), '-', '')), 0, 30)
                            placing '-' from 7) placing '-' from 14) placing '-' from 21);
        		INSERT INTO userrolesconfig (id, uuid, changedate, creationdate, userrole, sys_period, enabled) 
				VALUES (nextval('entity_seq'), _uuid, now(), now(),_userRole, NULL, _roleEnabled);
			ELSE
				UPDATE userrolesconfig SET  changedate =  now(), enabled = _roleEnabled WHERE id = _roleId;
		END IF;		
	END LOOP;
END
$$ LANGUAGE plpgsql

Campaign definitions in the database