Feature target type entity (#1162)
* Added Target Type model Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target Type JPA model Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target Type repository model classes Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed the name entity from Target Type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Refactored the Target Type models Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added the DB migration script and updated the Target Type models Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type in target Mapper Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Changed the target type ID to Long Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added MYSQL DB migration script and removed the deleted column for target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Updated the DB migration script for target table Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added manyToMany reltation between target type and Ds type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added POSTGRESQL DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added MSSQL SERVER DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added DB2 DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added missing license header and java docs Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added on delete cascade in DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target Type specification Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed the delete cascade and Added type API Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * fixed API doc build Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type management test Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type events test Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type update and unassign to target Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added API tests for assigning target type to target Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added missing license header Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added missing docs Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed sonar issues Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed license header build issue Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Updated the attribute name to target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed the review comments Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed unused error status variable Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target API to assign target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added the tests for assigning target type to target Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed the review comments for null check Signed-off-by: Anand kumar <anand.kumar@bosch-si.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
CREATE TABLE sp_target_type
|
||||
(
|
||||
id BIGINT GENERATED always AS IDENTITY NOT NULL,
|
||||
tenant VARCHAR(40) NOT NULL,
|
||||
colour VARCHAR(16),
|
||||
created_at BIGINT NOT NULL,
|
||||
created_by VARCHAR(64) NOT NULL,
|
||||
description VARCHAR(512),
|
||||
last_modified_at BIGINT NOT NULL,
|
||||
last_modified_by VARCHAR(64) NOT NULL,
|
||||
name VARCHAR(64) NOT NULL,
|
||||
optlock_revision INTEGER,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE INDEX sp_idx_target_type_prim
|
||||
ON sp_target_type (tenant, id);
|
||||
|
||||
CREATE TABLE sp_target_type_ds_type_relation
|
||||
(
|
||||
target_type BIGINT NOT NULL,
|
||||
distribution_set_type BIGINT NOT NULL,
|
||||
PRIMARY KEY (target_type, distribution_set_type)
|
||||
);
|
||||
|
||||
ALTER TABLE sp_target_type ADD CONSTRAINT uk_target_type_name UNIQUE (name, tenant);
|
||||
|
||||
ALTER TABLE sp_target ADD COLUMN target_type BIGINT;
|
||||
ALTER TABLE sp_target ADD CONSTRAINT fk_target_relation_target_type FOREIGN KEY (target_type) REFERENCES sp_target_type (id) ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE sp_target_type_ds_type_relation ADD CONSTRAINT fk_target_type_relation_target_type FOREIGN KEY (target_type) REFERENCES sp_target_type (id) ON DELETE CASCADE;
|
||||
ALTER TABLE sp_target_type_ds_type_relation ADD CONSTRAINT fk_target_type_relation_ds_type FOREIGN KEY (distribution_set_type) REFERENCES sp_distribution_set_type (id) ON DELETE CASCADE;
|
||||
@@ -0,0 +1,50 @@
|
||||
create table sp_target_type
|
||||
(
|
||||
id bigint generated by default as identity,
|
||||
created_at bigint,
|
||||
created_by varchar(64),
|
||||
last_modified_at bigint,
|
||||
last_modified_by varchar(64),
|
||||
optlock_revision bigint,
|
||||
tenant varchar(40) not null,
|
||||
description varchar(512),
|
||||
name varchar(64) not null,
|
||||
colour varchar(16),
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create table sp_target_type_ds_type_relation
|
||||
(
|
||||
target_type bigint not null,
|
||||
distribution_set_type bigint not null,
|
||||
primary key (target_type, distribution_set_type)
|
||||
);
|
||||
|
||||
alter table sp_target_type
|
||||
add constraint uk_target_type_name unique (name, tenant);
|
||||
|
||||
create index sp_idx_target_type_prim on sp_target_type (tenant, id);
|
||||
|
||||
alter table sp_target
|
||||
add column target_type bigint;
|
||||
|
||||
alter table sp_target
|
||||
add constraint fk_target_relation_target_type
|
||||
foreign key (target_type)
|
||||
references sp_target_type
|
||||
on delete set null;
|
||||
|
||||
alter table sp_target_type_ds_type_relation
|
||||
add constraint fk_target_type_relation_target_type
|
||||
foreign key (target_type)
|
||||
references sp_target_type
|
||||
on delete cascade;
|
||||
|
||||
alter table sp_target_type_ds_type_relation
|
||||
add constraint fk_target_type_relation_ds_type
|
||||
foreign key (distribution_set_type)
|
||||
references sp_distribution_set_type
|
||||
on delete cascade;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
create table sp_target_type
|
||||
(
|
||||
id bigint not null auto_increment,
|
||||
created_at bigint,
|
||||
created_by varchar(64),
|
||||
last_modified_at bigint,
|
||||
last_modified_by varchar(64),
|
||||
optlock_revision bigint,
|
||||
tenant varchar(40) not null,
|
||||
description varchar(512),
|
||||
name varchar(64) not null,
|
||||
colour varchar(16),
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create table sp_target_type_ds_type_relation
|
||||
(
|
||||
target_type bigint not null,
|
||||
distribution_set_type bigint not null,
|
||||
primary key (target_type, distribution_set_type)
|
||||
);
|
||||
|
||||
alter table sp_target_type
|
||||
add constraint uk_target_type_name unique (name, tenant);
|
||||
|
||||
create index sp_idx_target_type_prim on sp_target_type (tenant, id);
|
||||
|
||||
alter table sp_target
|
||||
add column target_type bigint;
|
||||
|
||||
alter table sp_target
|
||||
add constraint fk_target_relation_target_type
|
||||
foreign key (target_type)
|
||||
references sp_target_type (id)
|
||||
on delete set null;
|
||||
|
||||
alter table sp_target_type_ds_type_relation
|
||||
add constraint fk_target_type_relation_target_type
|
||||
foreign key (target_type)
|
||||
references sp_target_type (id)
|
||||
on delete cascade;
|
||||
|
||||
alter table sp_target_type_ds_type_relation
|
||||
add constraint fk_target_type_relation_ds_type
|
||||
foreign key (distribution_set_type)
|
||||
references sp_distribution_set_type (id)
|
||||
on delete cascade;
|
||||
@@ -0,0 +1,65 @@
|
||||
-- ------------ Write CREATE-SEQUENCE-stage scripts -----------
|
||||
|
||||
CREATE SEQUENCE IF NOT EXISTS sp_target_type_seq
|
||||
INCREMENT BY 1
|
||||
START WITH 1
|
||||
NO CYCLE;
|
||||
|
||||
-- ------------ Write CREATE-TABLE-stage scripts -----------
|
||||
|
||||
CREATE TABLE sp_target_type(
|
||||
id BIGINT NOT NULL DEFAULT nextval('sp_target_type_seq'),
|
||||
created_at BIGINT,
|
||||
created_by VARCHAR(64),
|
||||
last_modified_at BIGINT,
|
||||
last_modified_by VARCHAR(64),
|
||||
optlock_revision BIGINT,
|
||||
tenant VARCHAR(40) NOT NULL,
|
||||
description VARCHAR(512),
|
||||
name VARCHAR(64),
|
||||
colour VARCHAR(16)
|
||||
)
|
||||
WITH (
|
||||
OIDS=FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE sp_target_type_ds_type_relation(
|
||||
target_type BIGINT NOT NULL,
|
||||
distribution_set_type BIGINT NOT NULL
|
||||
)
|
||||
WITH (
|
||||
OIDS=FALSE
|
||||
);
|
||||
|
||||
-- ------------ Alter Table and Write INDEX scripts -----------
|
||||
|
||||
ALTER TABLE sp_target_type
|
||||
ADD CONSTRAINT pk_sp_target_type PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE sp_target_type
|
||||
ADD CONSTRAINT uk_target_type_name UNIQUE (name, tenant);
|
||||
|
||||
CREATE INDEX sp_idx_target_type_prim
|
||||
ON sp_target_type
|
||||
USING BTREE (tenant, id);
|
||||
|
||||
ALTER TABLE sp_target
|
||||
ADD COLUMN target_type BIGINT;
|
||||
|
||||
ALTER TABLE sp_target
|
||||
ADD CONSTRAINT fk_target_relation_target_type FOREIGN KEY (target_type)
|
||||
REFERENCES sp_target_type (id)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE sp_target_type_ds_type_relation
|
||||
ADD CONSTRAINT fk_target_type_relation_target_type FOREIGN KEY (target_type)
|
||||
REFERENCES sp_target_type (id)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE sp_target_type_ds_type_relation
|
||||
ADD CONSTRAINT fk_target_type_relation_ds_type FOREIGN KEY (distribution_set_type)
|
||||
REFERENCES sp_distribution_set_type (id)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE CASCADE;
|
||||
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE sp_target_type
|
||||
(
|
||||
id NUMERIC(19) IDENTITY NOT NULL,
|
||||
tenant VARCHAR(40) NOT NULL,
|
||||
colour VARCHAR(16) NULL,
|
||||
created_at NUMERIC(19) NOT NULL,
|
||||
created_by VARCHAR(64) NOT NULL,
|
||||
description VARCHAR(512) NULL,
|
||||
last_modified_at NUMERIC(19) NOT NULL,
|
||||
last_modified_by VARCHAR(64) NOT NULL,
|
||||
name VARCHAR(64) NOT NULL,
|
||||
optlock_revision INTEGER NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE INDEX sp_idx_target_type_prim ON sp_target_type (tenant, id);
|
||||
CREATE TABLE sp_target_type_ds_type_relation
|
||||
(
|
||||
target_type NUMERIC(19) NOT NULL,
|
||||
distribution_set_type NUMERIC(19) NOT NULL,
|
||||
PRIMARY KEY (target_type, distribution_set_type)
|
||||
);
|
||||
ALTER TABLE sp_target_type ADD CONSTRAINT uk_target_type_name UNIQUE (name, tenant);
|
||||
ALTER TABLE sp_target ADD target_type NUMERIC(19) NULL;
|
||||
ALTER TABLE sp_target ADD CONSTRAINT fk_target_relation_target_type FOREIGN KEY (target_type) REFERENCES sp_target_type (id) ON DELETE SET NULL;
|
||||
ALTER TABLE sp_target_type_ds_type_relation ADD CONSTRAINT fk_target_type_relation_target_type FOREIGN KEY (target_type) REFERENCES sp_target_type (id) ON DELETE CASCADE;
|
||||
ALTER TABLE sp_target_type_ds_type_relation ADD CONSTRAINT fk_target_type_relation_ds_type FOREIGN KEY (distribution_set_type) REFERENCES sp_distribution_set_type (id) ON DELETE CASCADE;
|
||||
|
||||
Reference in New Issue
Block a user