diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-08-08 02:58:27 -0700 |
---|---|---|
committer | Sébastien Determe <sd378r@intl.att.com> | 2017-08-08 12:34:18 +0000 |
commit | b3a21f74c5c31644eeef9634e33dde8a6972e3f8 (patch) | |
tree | 887149ac05a73987c318e93a7bfb79212b0d5e3f | |
parent | 08673dc040d7483e159a6e705993690538d7b117 (diff) |
Rework the Clamp db model
Rework the DB model + new SQL associated to that
Change-Id: Ibfa6e0bc9942f8b51a1681fab98502c462d34def
Issue-Id: CLAMP-1
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
13 files changed, 537 insertions, 349 deletions
diff --git a/extra/sql/bulkload/clds-create-db-objects.sql b/extra/sql/bulkload/clds-create-db-objects.sql index 5cbb7e01..3312daf5 100644 --- a/extra/sql/bulkload/clds-create-db-objects.sql +++ b/extra/sql/bulkload/clds-create-db-objects.sql @@ -1,18 +1,18 @@ -# +# # Create CLDS database objects (tables, etc.) # # CREATE DATABASE `camundabpm`; -USE `camundabpm`; -DROP USER 'camunda'; -CREATE USER 'camunda'; -GRANT ALL on camundabpm.* to 'camunda' identified by 'ndMSpw4CAM' with GRANT OPTION; -FLUSH PRIVILEGES; +USE `camundabpm`; +DROP USER 'camunda'; +CREATE USER 'camunda'; +GRANT ALL on camundabpm.* to 'camunda' identified by 'ndMSpw4CAM' with GRANT OPTION; +FLUSH PRIVILEGES; CREATE DATABASE `cldsdb4`; -USE `cldsdb4`; -DROP USER 'clds'; -CREATE USER 'clds'; +USE `cldsdb4`; +DROP USER 'clds'; +CREATE USER 'clds'; GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION; GRANT SELECT on mysql.proc TO 'clds'; FLUSH PRIVILEGES; @@ -32,7 +32,7 @@ CREATE TABLE template_bpmn ( template_bpmn_id VARCHAR(36) NOT NULL, template_id VARCHAR(36) NOT NULL, template_bpmn_text MEDIUMTEXT NOT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (template_bpmn_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -41,7 +41,7 @@ CREATE TABLE template_image ( template_image_id VARCHAR(36) NOT NULL, template_id VARCHAR(36) NOT NULL, template_image_text MEDIUMTEXT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (template_image_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -50,7 +50,7 @@ CREATE TABLE template_doc ( template_doc_id VARCHAR(36) NOT NULL, template_id VARCHAR(36) NOT NULL, template_doc_text MEDIUMTEXT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (template_doc_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -64,16 +64,20 @@ CREATE TABLE model ( event_id VARCHAR(36) NULL, control_name_prefix VARCHAR(80) NULL, control_name_uuid VARCHAR(36) NOT NULL, + service_type_id VARCHAR(80) NULL, + deployment_id VARCHAR(80) NULL, PRIMARY KEY (model_id), UNIQUE (model_name), - UNIQUE (control_name_uuid) + UNIQUE (control_name_uuid), + UNIQUE (service_type_id), + UNIQUE (deployment_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; CREATE TABLE model_properties ( model_prop_id VARCHAR(36) NOT NULL, model_id VARCHAR(36) NOT NULL, model_prop_text MEDIUMTEXT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (model_prop_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -82,7 +86,7 @@ CREATE TABLE model_blueprint ( model_blueprint_id VARCHAR(36) NOT NULL, model_id VARCHAR(36) NOT NULL, model_blueprint_text MEDIUMTEXT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (model_blueprint_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -104,7 +108,7 @@ CREATE TABLE event ( action_state_cd VARCHAR(80) NULL, prev_event_id VARCHAR(36) NULL, process_instance_id VARCHAR(80) NULL, - userid VARCHAR(8) NULL, + user_id VARCHAR(80) NULL, timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (event_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -131,7 +135,7 @@ ALTER TABLE template ADD CONSTRAINT template_doc_id_fkey01 FOREIGN KEY (template_doc_id) REFERENCES template_doc (template_doc_id); - + ALTER TABLE template_bpmn ADD CONSTRAINT template_id_fkey02 FOREIGN KEY (template_id) @@ -145,8 +149,8 @@ ALTER TABLE template_image ALTER TABLE template_doc ADD CONSTRAINT template_id_fkey04 FOREIGN KEY (template_id) - REFERENCES template (template_id); - + REFERENCES template (template_id); + ALTER TABLE model ADD CONSTRAINT template_id_fkey01 FOREIGN KEY (template_id) @@ -161,7 +165,7 @@ ALTER TABLE model ADD CONSTRAINT model_blueprint_id_fkey01 FOREIGN KEY (model_blueprint_id) REFERENCES model_blueprint (model_blueprint_id); - + ALTER TABLE model ADD CONSTRAINT event_id_fkey01 FOREIGN KEY (event_id) @@ -170,20 +174,19 @@ ALTER TABLE model ALTER TABLE model_properties ADD CONSTRAINT model_id_fkey01 FOREIGN KEY (model_id) - REFERENCES model (model_id); + REFERENCES model (model_id); ALTER TABLE model_blueprint ADD CONSTRAINT model_id_fkey02 FOREIGN KEY (model_id) - REFERENCES model (model_id); + REFERENCES model (model_id); ALTER TABLE model_instance ADD CONSTRAINT model_id_fkey04 FOREIGN KEY (model_id) - REFERENCES model (model_id); - + REFERENCES model (model_id); + ALTER TABLE event ADD CONSTRAINT model_id_fkey03 FOREIGN KEY (model_id) - REFERENCES model (model_id); - + REFERENCES model (model_id); diff --git a/extra/sql/bulkload/clds-stored-procedures.sql b/extra/sql/bulkload/clds-stored-procedures.sql index 41cc75e1..112cb2b5 100644 --- a/extra/sql/bulkload/clds-stored-procedures.sql +++ b/extra/sql/bulkload/clds-stored-procedures.sql @@ -1,7 +1,7 @@ -# -# CLDS stored procedures # +# CLDS stored procedures # + USE cldsdb4; DROP PROCEDURE IF EXISTS upd_event; @@ -10,43 +10,43 @@ DROP PROCEDURE IF EXISTS del_all_model_instances; DROP PROCEDURE IF EXISTS del_model_instance; DROP PROCEDURE IF EXISTS ins_model_instance; DROP PROCEDURE IF EXISTS set_model; -DROP PROCEDURE IF EXISTS get_model; -DROP PROCEDURE IF EXISTS get_model_template; +DROP PROCEDURE IF EXISTS get_model; +DROP PROCEDURE IF EXISTS get_model_template; DROP PROCEDURE IF EXISTS set_template; -DROP PROCEDURE IF EXISTS get_template; +DROP PROCEDURE IF EXISTS get_template; DELIMITER // CREATE PROCEDURE get_template (IN v_template_name VARCHAR(80), OUT v_template_id VARCHAR(36), OUT v_template_bpmn_id VARCHAR(36), - OUT v_template_bpmn_userid VARCHAR(8), + OUT v_template_bpmn_user_id VARCHAR(80), OUT v_template_bpmn_text MEDIUMTEXT, OUT v_template_image_id VARCHAR(36), - OUT v_template_image_userid VARCHAR(8), + OUT v_template_image_user_id VARCHAR(80), OUT v_template_image_text MEDIUMTEXT, OUT v_template_doc_id VARCHAR(36), - OUT v_template_doc_userid VARCHAR(8), + OUT v_template_doc_user_id VARCHAR(80), OUT v_template_doc_text MEDIUMTEXT) BEGIN SELECT t.template_id, tb.template_bpmn_id, - tb.userid, + tb.user_id, tb.template_bpmn_text, ti.template_image_id, - ti.userid, + ti.user_id, ti.template_image_text, td.template_doc_id, - td.userid, + td.user_id, td.template_doc_text INTO v_template_id, v_template_bpmn_id, - v_template_bpmn_userid, + v_template_bpmn_user_id, v_template_bpmn_text, v_template_image_id, - v_template_image_userid, + v_template_image_user_id, v_template_image_text, v_template_doc_id, - v_template_doc_userid, + v_template_doc_user_id, v_template_doc_text FROM template t, template_bpmn tb, @@ -59,17 +59,17 @@ BEGIN END; CREATE PROCEDURE set_template (IN v_template_name VARCHAR(80), - IN v_userid VARCHAR(8), + IN v_user_id VARCHAR(80), IN v_template_bpmn_text MEDIUMTEXT, IN v_template_image_text MEDIUMTEXT, IN v_template_doc_text MEDIUMTEXT, OUT v_template_id VARCHAR(36), OUT v_template_bpmn_id VARCHAR(36), - OUT v_template_bpmn_userid VARCHAR(8), + OUT v_template_bpmn_user_id VARCHAR(80), OUT v_template_image_id VARCHAR(36), - OUT v_template_image_userid VARCHAR(8), + OUT v_template_image_user_id VARCHAR(80), OUT v_template_doc_id VARCHAR(36), - OUT v_template_doc_userid VARCHAR(8)) + OUT v_template_doc_user_id VARCHAR(80)) BEGIN DECLARE v_old_template_bpmn_text MEDIUMTEXT; DECLARE v_old_template_image_text MEDIUMTEXT; @@ -79,13 +79,13 @@ BEGIN v_template_name, v_template_id, v_template_bpmn_id, - v_template_bpmn_userid, + v_template_bpmn_user_id, v_old_template_bpmn_text, v_template_image_id, - v_template_image_userid, + v_template_image_user_id, v_old_template_image_text, v_template_doc_id, - v_template_doc_userid, + v_template_doc_user_id, v_old_template_doc_text); IF v_template_id IS NULL THEN BEGIN @@ -98,23 +98,23 @@ BEGIN IF v_template_bpmn_id IS NULL OR v_template_bpmn_text <> v_old_template_bpmn_text THEN SET v_template_bpmn_id = UUID(); INSERT INTO template_bpmn - (template_bpmn_id, template_id, template_bpmn_text, userid) - VALUES (v_template_bpmn_id, v_template_id, v_template_bpmn_text, v_userid); - SET v_template_bpmn_userid = v_userid; + (template_bpmn_id, template_id, template_bpmn_text, user_id) + VALUES (v_template_bpmn_id, v_template_id, v_template_bpmn_text, v_user_id); + SET v_template_bpmn_user_id = v_user_id; END IF; IF v_template_image_id IS NULL OR v_template_image_text <> v_old_template_image_text THEN SET v_template_image_id = UUID(); INSERT INTO template_image - (template_image_id, template_id, template_image_text, userid) - VALUES (v_template_image_id, v_template_id, v_template_image_text, v_userid); - SET v_template_image_userid = v_userid; + (template_image_id, template_id, template_image_text, user_id) + VALUES (v_template_image_id, v_template_id, v_template_image_text, v_user_id); + SET v_template_image_user_id = v_user_id; END IF; IF v_template_doc_id IS NULL OR v_template_doc_text <> v_old_template_doc_text THEN SET v_template_doc_id = UUID(); INSERT INTO template_doc - (template_doc_id, template_id, template_doc_text, userid) - VALUES (v_template_doc_id, v_template_id, v_template_doc_text, v_userid); - SET v_template_doc_userid = v_userid; + (template_doc_id, template_id, template_doc_text, user_id) + VALUES (v_template_doc_id, v_template_id, v_template_doc_text, v_user_id); + SET v_template_doc_user_id = v_user_id; END IF; UPDATE template SET template_bpmn_id = v_template_bpmn_id, @@ -127,52 +127,58 @@ CREATE PROCEDURE get_model OUT v_control_name_prefix VARCHAR(80), INOUT v_control_name_uuid VARCHAR(36), OUT v_model_id VARCHAR(36), + OUT v_service_type_id VARCHAR(80), + OUT v_deployment_id VARCHAR(80), OUT v_template_name VARCHAR(80), OUT v_template_id VARCHAR(36), OUT v_model_prop_id VARCHAR(36), - OUT v_model_prop_userid VARCHAR(8), + OUT v_model_prop_user_id VARCHAR(80), OUT v_model_prop_text MEDIUMTEXT, OUT v_model_blueprint_id VARCHAR(36), - OUT v_model_blueprint_userid VARCHAR(8), + OUT v_model_blueprint_user_id VARCHAR(80), OUT v_model_blueprint_text MEDIUMTEXT, OUT v_event_id VARCHAR(36), OUT v_action_cd VARCHAR(80), OUT v_action_state_cd VARCHAR(80), OUT v_event_process_instance_id VARCHAR(80), - OUT v_event_userid VARCHAR(8)) + OUT v_event_user_id VARCHAR(80)) BEGIN SELECT m.control_name_prefix, m.control_name_uuid, m.model_id, + m.service_type_id, + m.deployment_id, t.template_name, m.template_id, mp.model_prop_id, - mp.userid, + mp.user_id, mp.model_prop_text, mb.model_blueprint_id, - mb.userid, + mb.user_id, mb.model_blueprint_text, e.event_id, e.action_cd, e.action_state_cd, e.process_instance_id, - e.userid + e.user_id INTO v_control_name_prefix, v_control_name_uuid, v_model_id, + v_service_type_id, + v_deployment_id, v_template_name, v_template_id, v_model_prop_id, - v_model_prop_userid, + v_model_prop_user_id, v_model_prop_text, v_model_blueprint_id, - v_model_blueprint_userid, + v_model_blueprint_user_id, v_model_blueprint_text, v_event_id, v_action_cd, v_action_state_cd, v_event_process_instance_id, - v_event_userid + v_event_user_id FROM model m, template t, model_properties mp, @@ -197,78 +203,84 @@ CREATE PROCEDURE get_model_template OUT v_control_name_prefix VARCHAR(80), INOUT v_control_name_uuid VARCHAR(36), OUT v_model_id VARCHAR(36), + OUT v_service_type_id VARCHAR(80), + OUT v_deployment_id VARCHAR(80), OUT v_template_name VARCHAR(80), OUT v_template_id VARCHAR(36), OUT v_model_prop_id VARCHAR(36), - OUT v_model_prop_userid VARCHAR(8), + OUT v_model_prop_user_id VARCHAR(80), OUT v_model_prop_text MEDIUMTEXT, OUT v_model_blueprint_id VARCHAR(36), - OUT v_model_blueprint_userid VARCHAR(8), + OUT v_model_blueprint_user_id VARCHAR(80), OUT v_model_blueprint_text MEDIUMTEXT, OUT v_template_bpmn_id VARCHAR(36), - OUT v_template_bpmn_userid VARCHAR(8), + OUT v_template_bpmn_user_id VARCHAR(80), OUT v_template_bpmn_text MEDIUMTEXT, OUT v_template_image_id VARCHAR(36), - OUT v_template_image_userid VARCHAR(8), + OUT v_template_image_user_id VARCHAR(80), OUT v_template_image_text MEDIUMTEXT, OUT v_template_doc_id VARCHAR(36), - OUT v_template_doc_userid VARCHAR(8), + OUT v_template_doc_user_id VARCHAR(80), OUT v_template_doc_text MEDIUMTEXT, OUT v_event_id VARCHAR(36), OUT v_action_cd VARCHAR(80), OUT v_action_state_cd VARCHAR(80), OUT v_event_process_instance_id VARCHAR(80), - OUT v_event_userid VARCHAR(8)) + OUT v_event_user_id VARCHAR(80)) BEGIN CALL get_model( v_model_name, v_control_name_prefix, v_control_name_uuid, v_model_id, + v_service_type_id, + v_deployment_id, v_template_name, v_template_id, v_model_prop_id, - v_model_prop_userid, + v_model_prop_user_id, v_model_prop_text, v_model_blueprint_id, - v_model_blueprint_userid, + v_model_blueprint_user_id, v_model_blueprint_text, v_event_id, v_action_cd, v_action_state_cd, v_event_process_instance_id, - v_event_userid); + v_event_user_id); CALL get_template( v_template_name, v_template_id, v_template_bpmn_id, - v_template_bpmn_userid, + v_template_bpmn_user_id, v_template_bpmn_text, v_template_image_id, - v_template_image_userid, + v_template_image_user_id, v_template_image_text, v_template_doc_id, - v_template_doc_userid, + v_template_doc_user_id, v_template_doc_text); END; CREATE PROCEDURE set_model (IN v_model_name VARCHAR(80), IN v_template_id VARCHAR(36), - IN v_userid VARCHAR(8), + IN v_user_id VARCHAR(80), IN v_model_prop_text MEDIUMTEXT, IN v_model_blueprint_text MEDIUMTEXT, + IN v_service_type_id VARCHAR(80), + IN v_deployment_id VARCHAR(80), INOUT v_control_name_prefix VARCHAR(80), INOUT v_control_name_uuid VARCHAR(36), OUT v_model_id VARCHAR(36), OUT v_model_prop_id VARCHAR(36), - OUT v_model_prop_userid VARCHAR(8), + OUT v_model_prop_user_id VARCHAR(80), OUT v_model_blueprint_id VARCHAR(36), - OUT v_model_blueprint_userid VARCHAR(8), + OUT v_model_blueprint_user_id VARCHAR(80), OUT v_event_id VARCHAR(36), OUT v_action_cd VARCHAR(80), OUT v_action_state_cd VARCHAR(80), OUT v_event_process_instance_id VARCHAR(80), - OUT v_event_userid VARCHAR(8)) + OUT v_event_user_id VARCHAR(80)) BEGIN DECLARE v_old_template_name VARCHAR(80); DECLARE v_old_template_id VARCHAR(36); @@ -276,25 +288,29 @@ BEGIN DECLARE v_old_control_name_uuid VARCHAR(36); DECLARE v_old_model_prop_text MEDIUMTEXT; DECLARE v_old_model_blueprint_text MEDIUMTEXT; + DECLARE v_old_service_type_id VARCHAR(80); + DECLARE v_old_deployment_id VARCHAR(80); SET v_model_id = NULL; CALL get_model( v_model_name, v_old_control_name_prefix, v_old_control_name_uuid, v_model_id, + v_old_service_type_id, + v_old_deployment_id, v_old_template_name, v_old_template_id, v_model_prop_id, - v_model_prop_userid, + v_model_prop_user_id, v_old_model_prop_text, v_model_blueprint_id, - v_model_blueprint_userid, + v_model_blueprint_user_id, v_old_model_blueprint_text, v_event_id, v_action_cd, v_action_state_cd, v_event_process_instance_id, - v_event_userid); + v_event_user_id); IF v_model_id IS NULL THEN BEGIN # UUID can be provided initially but cannot be updated @@ -304,16 +320,16 @@ BEGIN END IF; SET v_model_id = v_control_name_uuid; INSERT INTO model - (model_id, model_name, template_id, control_name_prefix, control_name_uuid) - VALUES (v_model_id, v_model_name, v_template_id, v_control_name_prefix, v_control_name_uuid); + (model_id, model_name, template_id, control_name_prefix, control_name_uuid, service_type_id, deployment_id) + VALUES (v_model_id, v_model_name, v_template_id, v_control_name_prefix, v_control_name_uuid, v_service_type_id, v_deployment_id); # since just created model, insert CREATED event as initial default event SET v_action_cd = 'CREATE'; SET v_action_state_cd = 'COMPLETED'; - SET v_event_userid = v_userid; + SET v_event_user_id = v_user_id; SET v_event_id = UUID(); INSERT INTO event - (event_id, model_id, action_cd, action_state_cd, userid) - VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_event_userid); + (event_id, model_id, action_cd, action_state_cd, user_id) + VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_event_user_id); UPDATE model SET event_id = v_event_id WHERE model_id = v_model_id; @@ -331,21 +347,23 @@ BEGIN IF v_model_prop_id IS NULL OR v_model_prop_text <> v_old_model_prop_text THEN SET v_model_prop_id = UUID(); INSERT INTO model_properties - (model_prop_id, model_id, model_prop_text, userid) - VALUES (v_model_prop_id, v_model_id, v_model_prop_text, v_userid); - SET v_model_prop_userid = v_userid; + (model_prop_id, model_id, model_prop_text, user_id) + VALUES (v_model_prop_id, v_model_id, v_model_prop_text, v_user_id); + SET v_model_prop_user_id = v_user_id; END IF; IF v_model_blueprint_id IS NULL OR v_model_blueprint_text <> v_old_model_blueprint_text THEN SET v_model_blueprint_id = UUID(); INSERT INTO model_blueprint - (model_blueprint_id, model_id, model_blueprint_text, userid) - VALUES (v_model_blueprint_id, v_model_id, v_model_blueprint_text, v_userid); - SET v_model_blueprint_userid = v_userid; + (model_blueprint_id, model_id, model_blueprint_text, user_id) + VALUES (v_model_blueprint_id, v_model_id, v_model_blueprint_text, v_user_id); + SET v_model_blueprint_user_id = v_user_id; END IF; UPDATE model SET control_name_prefix = v_control_name_prefix, model_prop_id = v_model_prop_id, - model_blueprint_id = v_model_blueprint_id + model_blueprint_id = v_model_blueprint_id, + service_type_id = v_service_type_id, + deployment_id = v_deployment_id WHERE model_id = v_model_id; END; CREATE PROCEDURE ins_model_instance @@ -396,7 +414,7 @@ CREATE PROCEDURE ins_event (IN v_model_name VARCHAR(80), IN v_control_name_prefix VARCHAR(80), IN v_control_name_uuid VARCHAR(36), - IN v_userid VARCHAR(8), + IN v_user_id VARCHAR(80), IN v_action_cd VARCHAR(80), IN v_action_state_cd VARCHAR(80), IN v_process_instance_id VARCHAR(80), @@ -413,8 +431,8 @@ BEGIN OR m.control_name_uuid = v_control_name_uuid; SET v_event_id = UUID(); INSERT INTO event - (event_id, model_id, action_cd, action_state_cd, prev_event_id, process_instance_id, userid) - VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_prev_event_id, v_process_instance_id, v_userid); + (event_id, model_id, action_cd, action_state_cd, prev_event_id, process_instance_id, user_id) + VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_prev_event_id, v_process_instance_id, v_user_id); UPDATE model SET event_id = v_event_id WHERE model_id = v_model_id; diff --git a/extra/sql/drop/clds-drop-db-objects.sql b/extra/sql/drop/clds-drop-db-objects.sql index 487aa49d..478eaf0e 100644 --- a/extra/sql/drop/clds-drop-db-objects.sql +++ b/extra/sql/drop/clds-drop-db-objects.sql @@ -1,6 +1,5 @@ -# -# Drop CLDS database objects (tables, etc.) # +# Drop CLDS database objects (tables, etc.) # @@ -10,7 +9,7 @@ ALTER TABLE template DROP FOREIGN KEY template_bpmn_id_fkey01; ALTER TABLE template DROP FOREIGN KEY template_doc_id_fkey01; - + ALTER TABLE model DROP FOREIGN KEY template_id_fkey01; ALTER TABLE model @@ -20,6 +19,8 @@ ALTER TABLE model ALTER TABLE model DROP FOREIGN KEY event_id_fkey01; +DROP TABLE clds_service_cache; + DROP TABLE model_instance; DROP TABLE model_blueprint; DROP TABLE model_properties; diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java index 03254783..e0d10097 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java @@ -27,10 +27,10 @@ import java.io.Serializable; public class CldsAlarmCondition implements Serializable { - private static final long serialVersionUID = 1L; - private String eventSourceType; - private String alarmConditionKey; - private String severity; + private static final long serialVersionUID = 4271364536747705555L; + private String eventSourceType; + private String alarmConditionKey; + private String severity; public String getEventSourceType() { return eventSourceType; diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java b/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java index 658e21f9..4b2a2e30 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java @@ -23,12 +23,16 @@ package org.onap.clamp.clds.model; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectOutputStream; public class CldsDBServiceCache { - private String invariantId; - private String serviceId; + private String invariantId; + private String serviceId; private InputStream cldsDataInstream; public String getInvariantId() { diff --git a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java index 8379e502..3b9c1d21 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -29,29 +29,34 @@ import org.onap.clamp.clds.dao.CldsDao; * Represent a CLDS Event. */ public class CldsEvent { - public static final String ACTION_CREATE = "CREATE"; - public static final String ACTION_SUBMIT = "SUBMIT"; - public static final String ACTION_RESUBMIT = "RESUBMIT"; // an update before model is active - public static final String ACTION_DISTRIBUTE = "DISTRIBUTE"; // only from dcae - public static final String ACTION_DEPLOY = "DEPLOY"; // only from dcae - public static final String ACTION_UNDEPLOY = "UNDEPLOY"; // only from dcae - public static final String ACTION_UPDATE = "UPDATE"; - public static final String ACTION_DELETE = "DELETE"; - public static final String ACTION_STOP = "STOP"; - public static final String ACTION_RESTART = "RESTART"; + public static final String ACTION_TEST = "TEST"; + public static final String ACTION_CREATE = "CREATE"; + public static final String ACTION_SUBMIT = "SUBMIT"; + // an update before model is active + public static final String ACTION_RESUBMIT = "RESUBMIT"; + // only from dcae + public static final String ACTION_DISTRIBUTE = "DISTRIBUTE"; + // only from dcae + public static final String ACTION_DEPLOY = "DEPLOY"; + // only from dcae + public static final String ACTION_UNDEPLOY = "UNDEPLOY"; + public static final String ACTION_UPDATE = "UPDATE"; + public static final String ACTION_DELETE = "DELETE"; + public static final String ACTION_STOP = "STOP"; + public static final String ACTION_RESTART = "RESTART"; public static final String ACTION_STATE_INITIATED = "INITIATED"; - public static final String ACTION_STATE_SENT = "SENT"; + public static final String ACTION_STATE_SENT = "SENT"; public static final String ACTION_STATE_COMPLETED = "COMPLETED"; - public static final String ACTION_STATE_RECEIVED = "RECEIVED"; - public static final String ACTION_STATE_ERROR = "ERROR"; - public static final String ACTION_STATE_ANY = null; + public static final String ACTION_STATE_RECEIVED = "RECEIVED"; + public static final String ACTION_STATE_ERROR = "ERROR"; + public static final String ACTION_STATE_ANY = null; - private String id; - private String actionCd; - private String actionStateCd; - private String processInstanceId; - private String userid; + private String id; + private String actionCd; + private String actionStateCd; + private String processInstanceId; + private String userid; public String getId() { return id; @@ -70,14 +75,16 @@ public class CldsEvent { * @param processInstanceId * @return */ - public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd, String actionStateCd, String processInstanceId) { + public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd, + String actionStateCd, String processInstanceId) { CldsModel model = CldsModel.createUsingControlName(controlName); - return insEvent(cldsDao, model, actionCd, actionStateCd, processInstanceId); + return insEvent(cldsDao, model, userid, actionCd, actionStateCd, processInstanceId); } /** - * Insert event using controlNameUuid to find the model. - * This method meant for processing events from dcae. + * Insert event using controlNameUuid to find the model. This method meant + * for processing events from dcae. + * * @param cldsDao * @param model * @param actionCd @@ -85,8 +92,10 @@ public class CldsEvent { * @param processInstanceId * @return */ - public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String actionCd, String actionStateCd, String processInstanceId) { + public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String userId, String actionCd, String actionStateCd, + String processInstanceId) { CldsEvent event = new CldsEvent(); + event.setUserid(userId); event.setActionCd(actionCd); event.setActionStateCd(actionStateCd); event.setProcessInstanceId(processInstanceId); @@ -95,9 +104,23 @@ public class CldsEvent { } /** - * Check if actionCd and actionStateCd are equal to the supplied checkActionCd and checkActionStateCd. - * Treat checkActionStateCd == null as a wildcard - * checkActionCd should not be null. + * Check if actionCd is equal to the supplied checkActionCd checkActionCd + * should not be null. + * + * @param checkActionCd + * @return + */ + public boolean isActionCd(String checkActionCd) { + if (actionCd == null) { + return false; + } + return actionCd.equals(checkActionCd); + } + + /** + * Check if actionCd and actionStateCd are equal to the supplied + * checkActionCd and checkActionStateCd. Treat checkActionStateCd == null as + * a wildcard checkActionCd should not be null. * * @param checkActionCd * @param checkActionStateCd @@ -107,7 +130,8 @@ public class CldsEvent { if (actionCd == null) { return false; } - // treat checkActionStateCd == null as a wildcard (same for actionStateCd, although it shouln't be null...) + // treat checkActionStateCd == null as a wildcard (same for + // actionStateCd, although it shouln't be null...) if (checkActionStateCd == null || actionStateCd == null) { return actionCd.equals(checkActionCd); } @@ -133,7 +157,8 @@ public class CldsEvent { } /** - * @param actionCd the actionCd to set + * @param actionCd + * the actionCd to set */ public void setActionCd(String actionCd) { this.actionCd = actionCd; @@ -147,7 +172,8 @@ public class CldsEvent { } /** - * @param actionStateCd the actionStateCd to set + * @param actionStateCd + * the actionStateCd to set */ public void setActionStateCd(String actionStateCd) { this.actionStateCd = actionStateCd; @@ -161,7 +187,8 @@ public class CldsEvent { } /** - * @param processInstanceId the processInstanceId to set + * @param processInstanceId + * the processInstanceId to set */ public void setProcessInstanceId(String processInstanceId) { this.processInstanceId = processInstanceId; @@ -175,7 +202,8 @@ public class CldsEvent { } /** - * @param userid the userid to set + * @param userid + * the userid to set */ public void setUserid(String userid) { this.userid = userid; diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java index 4d4f3aab..e34f47d9 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -23,58 +23,72 @@ package org.onap.clamp.clds.model; -import org.onap.clamp.clds.dao.CldsDao; -import org.jboss.resteasy.spi.BadRequestException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.ws.rs.NotFoundException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import javax.ws.rs.NotFoundException; + +import org.jboss.resteasy.spi.BadRequestException; +import org.onap.clamp.clds.dao.CldsDao; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + /** * Represent a CLDS Model. */ public class CldsModel { - private static final Logger logger = LoggerFactory.getLogger(CldsModel.class); - - private static final int UUID_LENGTH = 36; - - public static final String STATUS_DESIGN = "DESIGN"; - public static final String STATUS_DISTRIBUTED = "DISTRIBUTED"; - public static final String STATUS_ACTIVE = "ACTIVE"; - public static final String STATUS_STOPPED = "STOPPED"; - public static final String STATUS_DELETING = "DELETING"; - public static final String STATUS_ERROR = "ERROR"; // manual intervention required - public static final String STATUS_UNKNOWN = "UNKNOWN"; - - private String id; - private String templateId; - private String templateName; - private String name; - private String controlNamePrefix; - private String controlNameUuid; - private String bpmnId; - private String bpmnUserid; - private String bpmnText; - private String propId; - private String propUserid; - private String propText; - private String imageId; - private String imageUserid; - private String imageText; - private String docId; - private String docUserid; - private String docText; - private String blueprintId; - private String blueprintUserid; - private String blueprintText; - private CldsEvent event; - private String status; - private List<String> permittedActionCd; + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsModel.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + private static final int UUID_LENGTH = 36; + + public static final String STATUS_DESIGN = "DESIGN"; + public static final String STATUS_DISTRIBUTED = "DISTRIBUTED"; + public static final String STATUS_ACTIVE = "ACTIVE"; + public static final String STATUS_STOPPED = "STOPPED"; + public static final String STATUS_DELETING = "DELETING"; + public static final String STATUS_ERROR = "ERROR"; // manual + // intervention + // required + public static final String STATUS_UNKNOWN = "UNKNOWN"; + + private String id; + private String templateId; + private String templateName; + private String name; + private String controlNamePrefix; + private String controlNameUuid; + private String bpmnId; + private String bpmnUserid; + private String bpmnText; + private String propId; + private String propUserid; + private String propText; + private String imageId; + private String imageUserid; + private String imageText; + private String docId; + private String docUserid; + private String docText; + private String blueprintId; + private String blueprintUserid; + private String blueprintText; + private CldsEvent event; + private String status; + private List<String> permittedActionCd; private List<CldsModelInstance> cldsModelInstanceList; + private String typeId; + private String typeName; + + private String dispatcherResponse; + + private String deploymentId; + + private boolean userAuthorizedToUpdate; + /** * Construct empty model. */ @@ -100,6 +114,16 @@ public class CldsModel { return model; } + public boolean canInventoryCall() { + boolean canCall = false; + /* Below checks the clds ecent is submit/resubmit */ + + if ((event.isActionCd(CldsEvent.ACTION_SUBMIT) || event.isActionCd(CldsEvent.ACTION_RESUBMIT))) { + canCall = true; + } + return canCall; + } + /** * Save model to DB. * @@ -113,8 +137,8 @@ public class CldsModel { } /** - * Insert a new event for the new action. - * Throw IllegalArgumentException if requested actionCd is not permitted. + * Insert a new event for the new action. Throw IllegalArgumentException if + * requested actionCd is not permitted. * * @param cldsDao * @param userid @@ -123,7 +147,7 @@ public class CldsModel { */ public void insEvent(CldsDao cldsDao, String userid, String actionCd, String actionStateCd) { validateAction(actionCd); - event = CldsEvent.insEvent(cldsDao, this, actionCd, actionStateCd, null); + event = CldsEvent.insEvent(cldsDao, this, userid, actionCd, actionStateCd, null); determineStatus(); determinePermittedActionCd(); } @@ -148,19 +172,20 @@ public class CldsModel { status = STATUS_DESIGN; } else if (event.isActionStateCd(CldsEvent.ACTION_STATE_ERROR)) { status = STATUS_ERROR; - } else if (event.isActionAndStateCd(CldsEvent.ACTION_CREATE, CldsEvent.ACTION_STATE_ANY) || - event.isActionAndStateCd(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_STATE_ANY) || - event.isActionAndStateCd(CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_STATE_ANY) || - event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_RECEIVED)) { + } else if (event.isActionAndStateCd(CldsEvent.ACTION_CREATE, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_RECEIVED)) { status = STATUS_DESIGN; - } else if (event.isActionAndStateCd(CldsEvent.ACTION_DISTRIBUTE, CldsEvent.ACTION_STATE_RECEIVED) || - event.isActionAndStateCd(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_STATE_RECEIVED)) { + } else if (event.isActionAndStateCd(CldsEvent.ACTION_DISTRIBUTE, CldsEvent.ACTION_STATE_RECEIVED) + || event.isActionAndStateCd(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_STATE_RECEIVED)) { status = STATUS_DISTRIBUTED; } else if (event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_SENT)) { status = STATUS_DELETING; - } else if (event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_RECEIVED) || - event.isActionAndStateCd(CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_ANY) || - event.isActionAndStateCd(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STATE_ANY)) { + } else if (event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_RECEIVED) + || event.isActionAndStateCd(CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_ANY)) { status = STATUS_ACTIVE; } else if (event.isActionAndStateCd(CldsEvent.ACTION_STOP, CldsEvent.ACTION_STATE_ANY)) { status = STATUS_STOPPED; @@ -169,7 +194,8 @@ public class CldsModel { } /** - * Get the actionCd from current event. If none, default value is CldsEvent.ACTION_CREATE + * Get the actionCd from current event. If none, default value is + * CldsEvent.ACTION_CREATE * * @return */ @@ -183,7 +209,8 @@ public class CldsModel { } /** - * Get the actionStateCd from current event. If none, default value is CldsEvent.ACTION_STATE_COMPLETED + * Get the actionStateCd from current event. If none, default value is + * CldsEvent.ACTION_STATE_COMPLETED * * @return */ @@ -197,28 +224,36 @@ public class CldsModel { } /** - * Determine permittedActionCd list using the actionCd from the current event. + * Determine permittedActionCd list using the actionCd from the current + * event. */ private void determinePermittedActionCd() { String actionCd = getCurrentActionCd(); switch (actionCd) { case CldsEvent.ACTION_CREATE: - permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMIT); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_TEST); break; case CldsEvent.ACTION_SUBMIT: case CldsEvent.ACTION_RESUBMIT: - // for 1702 delete is not currently implemented (and resubmit requires manually deleting artifact from asdc + // for 1702 delete is not currently implemented (and resubmit + // requires manually deleting artifact from sdc permittedActionCd = Arrays.asList(CldsEvent.ACTION_RESUBMIT); break; case CldsEvent.ACTION_DISTRIBUTE: + permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT); + break; case CldsEvent.ACTION_UNDEPLOY: - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY); break; case CldsEvent.ACTION_DEPLOY: + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_UPDATE, + CldsEvent.ACTION_STOP); + break; case CldsEvent.ACTION_RESTART: case CldsEvent.ACTION_UPDATE: // for 1702 delete is not currently implemented - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP, + CldsEvent.ACTION_UNDEPLOY); break; case CldsEvent.ACTION_DELETE: if (getCurrentActionStateCd().equals(CldsEvent.ACTION_STATE_SENT)) { @@ -229,7 +264,8 @@ public class CldsModel { break; case CldsEvent.ACTION_STOP: // for 1702 delete is not currently implemented - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART, + CldsEvent.ACTION_UNDEPLOY); break; default: logger.warn("Invalid current actionCd: " + actionCd); @@ -237,22 +273,26 @@ public class CldsModel { } /** - * Validate requestedActionCd - determine permittedActionCd and then check if contained in permittedActionCd - * Throw IllegalArgumentException if requested actionCd is not permitted. + * Validate requestedActionCd - determine permittedActionCd and then check + * if contained in permittedActionCd Throw IllegalArgumentException if + * requested actionCd is not permitted. * * @param requestedActionCd */ public void validateAction(String requestedActionCd) { determinePermittedActionCd(); if (!permittedActionCd.contains(requestedActionCd)) { - throw new IllegalArgumentException("Invalid requestedActionCd: " + requestedActionCd + ". Given current actionCd: " + getCurrentActionCd() + ", the permittedActionCd: " + permittedActionCd); + throw new IllegalArgumentException( + "Invalid requestedActionCd: " + requestedActionCd + ". Given current actionCd: " + + getCurrentActionCd() + ", the permittedActionCd: " + permittedActionCd); } } /** - * Extract the UUID portion of a given full control name (controlNamePrefix + controlNameUuid). - * No fields are populated other than controlNamePrefix and controlNameUuid. - * Throws BadRequestException if length of given control name is less than UUID_LENGTH. + * Extract the UUID portion of a given full control name (controlNamePrefix + * + controlNameUuid). No fields are populated other than controlNamePrefix + * and controlNameUuid. Throws BadRequestException if length of given + * control name is less than UUID_LENGTH. * * @param fullControlName * @return @@ -265,7 +305,8 @@ public class CldsModel { len = fullControlName.length(); } if (len < UUID_LENGTH) { - throw new BadRequestException("closed loop id / control name length, " + len + ", less than the minimum of: " + UUID_LENGTH); + throw new BadRequestException( + "closed loop id / control name length, " + len + ", less than the minimum of: " + UUID_LENGTH); } CldsModel model = new CldsModel(); model.setControlNamePrefix(fullControlName.substring(0, len - UUID_LENGTH)); @@ -291,19 +332,22 @@ public class CldsModel { CldsModel cldsModel = createUsingControlName(controlName); cldsModel = cldsDao.getModelByUuid(cldsModel.getControlNameUuid()); cldsModel.determineStatus(); - if (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_UNDEPLOY) || - (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_DEPLOY) && (cldsModel.getStatus().equals(STATUS_DISTRIBUTED) || cldsModel.getStatus().equals(STATUS_DESIGN)))) { - CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), CldsEvent.ACTION_STATE_RECEIVED, null); + if (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_UNDEPLOY) || (dcaeEvent.getCldsActionCd() + .equals(CldsEvent.ACTION_DEPLOY) + && (cldsModel.getStatus().equals(STATUS_DISTRIBUTED) || cldsModel.getStatus().equals(STATUS_DESIGN)))) { + CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), + CldsEvent.ACTION_STATE_RECEIVED, null); } cldsDao.insModelInstance(cldsModel, dcaeEvent.getInstances()); return cldsModel; } /** - * To remove modelInstance from the database - * This method is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of - * deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that - * are still deployed with any not on the list considered undeployed. + * To remove modelInstance from the database This method is defunct - DCAE + * Proxy will not undeploy individual instances. It will send an empty list + * of deployed instances to indicate all have been removed. Or it will send + * an updated list to indicate those that are still deployed with any not on + * the list considered undeployed. * * @param cldsDao * @param dcaeEvent @@ -311,7 +355,8 @@ public class CldsModel { @SuppressWarnings("unused") private static CldsModel removeModelInstance(CldsDao cldsDao, DcaeEvent dcaeEvent) { String controlName = dcaeEvent.getControlName(); - //cldsModel = cldsDao.delModelInstance(cldsModel.getControlNameUuid(), dcaeEvent.getInstances() ); + // cldsModel = cldsDao.delModelInstance(cldsModel.getControlNameUuid(), + // dcaeEvent.getInstances() ); return createUsingControlName(controlName); } @@ -323,12 +368,28 @@ public class CldsModel { } /** - * @param name the name to set + * @param name + * the name to set */ public void setName(String name) { this.name = name; } + /** + * @return the typeName + */ + public String getTypeName() { + return typeName; + } + + /** + * @param name + * the typeName to set + */ + public void setTypeName(String typeName) { + this.typeName = typeName; + } + public String getTemplateId() { return templateId; } @@ -345,7 +406,8 @@ public class CldsModel { } /** - * @param controlNamePrefix the controlNamePrefix to set + * @param controlNamePrefix + * the controlNamePrefix to set */ public void setControlNamePrefix(String controlNamePrefix) { this.controlNamePrefix = controlNamePrefix; @@ -359,13 +421,13 @@ public class CldsModel { } /** - * @param controlNameUuid the controlNameUuid to set + * @param controlNameUuid + * the controlNameUuid to set */ public void setControlNameUuid(String controlNameUuid) { this.controlNameUuid = controlNameUuid; } - /** * @return the propUserid */ @@ -374,7 +436,8 @@ public class CldsModel { } /** - * @param propUserid the propUserid to set + * @param propUserid + * the propUserid to set */ public void setPropUserid(String propUserid) { this.propUserid = propUserid; @@ -388,7 +451,8 @@ public class CldsModel { } /** - * @param propText the propText to set + * @param propText + * the propText to set */ public void setPropText(String propText) { this.propText = propText; @@ -426,7 +490,8 @@ public class CldsModel { } /** - * @param event the event to set + * @param event + * the event to set */ public void setEvent(CldsEvent event) { this.event = event; @@ -440,7 +505,8 @@ public class CldsModel { } /** - * @param status the status to set + * @param status + * the status to set */ public void setStatus(String status) { this.status = status; @@ -454,7 +520,8 @@ public class CldsModel { } /** - * @param permittedActionCd the permittedActionCd to set + * @param permittedActionCd + * the permittedActionCd to set */ public void setPermittedActionCd(List<String> permittedActionCd) { this.permittedActionCd = permittedActionCd; @@ -556,6 +623,14 @@ public class CldsModel { this.docText = docText; } + public String getTypeId() { + return typeId; + } + + public void setTypeId(String typeId) { + this.typeId = typeId; + } + public List<CldsModelInstance> getCldsModelInstanceList() { if (cldsModelInstanceList == null) { cldsModelInstanceList = new ArrayList<>(); @@ -567,4 +642,28 @@ public class CldsModel { this.cldsModelInstanceList = cldsModelInstanceList; } + public void setDispatcherResponse(String dispatcherResponse) { + this.dispatcherResponse = dispatcherResponse; + + } + + public String getDispatcherResponse() { + return this.dispatcherResponse; + } + + public String getDeploymentId() { + return deploymentId; + } + + public void setDeploymentId(String deploymentId) { + this.deploymentId = deploymentId; + } + + public boolean isUserAuthorizedToUpdate() { + return userAuthorizedToUpdate; + } + + public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) { + this.userAuthorizedToUpdate = userAuthorizedToUpdate; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java index 89108393..dad7cb61 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -23,25 +23,29 @@ package org.onap.clamp.clds.model; -import org.onap.clamp.clds.dao.CldsDao; -import org.onap.clamp.clds.service.CldsService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.ws.rs.NotAuthorizedException; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import javax.ws.rs.NotAuthorizedException; + +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.service.CldsService; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + public class CldsServiceData implements Serializable { - private static final Logger logger = LoggerFactory.getLogger(CldsServiceData.class); - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -9153372664377279423L; + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsServiceData.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String serviceInvariantUUID; - private String serviceUUID; - private Long ageOfRecord; - private List<CldsVfData> cldsVfs; + private String serviceInvariantUUID; + private String serviceUUID; + private Long ageOfRecord; + private List<CldsVfData> cldsVfs; public String getServiceInvariantUUID() { return serviceInvariantUUID; @@ -84,8 +88,8 @@ public class CldsServiceData implements Serializable { } /** - * Filter out any VFs that the user is not authorized for. - * Use the CldsService to determine if the user is authorized for a VF. + * Filter out any VFs that the user is not authorized for. Use the + * CldsService to determine if the user is authorized for a VF. * * @param svc */ @@ -95,14 +99,16 @@ public class CldsServiceData implements Serializable { logger.debug("cldsVfs == null"); } else { for (CldsVfData vf : cldsVfs) { - // if user is authorized for the VF then add it to the filtered list + // if user is authorized for the VF then add it to the filtered + // list try { if (svc.isAuthorizedForVf(vf.getVfInvariantResourceUUID())) { filteredCldsVfs.add(vf); } } catch (NotAuthorizedException e) { logger.debug("user not authorized for {}", vf.getVfInvariantResourceUUID()); - // when not NotAuthorizedException - don't add to filteredCldsVfs list + // when not NotAuthorizedException - don't add to + // filteredCldsVfs list } } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java index 6e2c8d70..a96ee381 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -23,35 +23,39 @@ package org.onap.clamp.clds.model; -import org.onap.clamp.clds.dao.CldsDao; - import javax.ws.rs.NotFoundException; +import org.onap.clamp.clds.dao.CldsDao; + /** * Represent a CLDS Model. */ public class CldsTemplate { - public static final String STATUS_DESIGN = "DESIGN"; - public static final String STATUS_ACTIVE = "ACTIVE"; - public static final String STATUS_STOPPED = "STOPPED"; + public static final String STATUS_DESIGN = "DESIGN"; + public static final String STATUS_ACTIVE = "ACTIVE"; + public static final String STATUS_STOPPED = "STOPPED"; public static final String STATUS_DELETING = "DELETING"; - public static final String STATUS_ERROR = "ERROR"; // manual intervention required - public static final String STATUS_UNKNOWN = "UNKNOWN"; - - private String id; - private String name; - private String controlNamePrefix; - private String controlNameUuid; - private String bpmnId; - private String bpmnUserid; - private String bpmnText; - private String imageId; - private String imageUserid; - private String imageText; - private String propId; - private String propUserid; - private String propText; + public static final String STATUS_ERROR = "ERROR"; // manual + // intervention + // required + public static final String STATUS_UNKNOWN = "UNKNOWN"; + + private String id; + private String name; + private String controlNamePrefix; + private String controlNameUuid; + private String bpmnId; + private String bpmnUserid; + private String bpmnText; + private String imageId; + private String imageUserid; + private String imageText; + private String propId; + private String propUserid; + private String propText; + + private boolean userAuthorizedToUpdate; /** * Save template to DB. @@ -183,4 +187,11 @@ public class CldsTemplate { this.imageId = imageId; } + public boolean isUserAuthorizedToUpdate() { + return userAuthorizedToUpdate; + } + + public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) { + this.userAuthorizedToUpdate = userAuthorizedToUpdate; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfData.java index dbcfb346..aa5712c5 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsVfData.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsVfData.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -28,11 +28,20 @@ import java.util.List; public class CldsVfData implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -5069670140274203606L; + private String vfName; + private String vfInvariantResourceUUID; + private List<CldsVfcData> cldsVfcs; - private String vfName; - private String vfInvariantResourceUUID; - private List<CldsVfcData> cldsVfcs; + private List<CldsVfKPIData> cldsKPIList; + + public List<CldsVfKPIData> getCldsKPIList() { + return cldsKPIList; + } + + public void setCldsKPIList(List<CldsVfKPIData> cldsKPIList) { + this.cldsKPIList = cldsKPIList; + } public String getVfName() { return vfName; diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java index 2d56d01f..3828489c 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java @@ -28,10 +28,9 @@ import java.util.List; public class CldsVfcData implements Serializable { - private static final long serialVersionUID = 1L; - - private String vfcName; - private String vfcInvariantResourceUUID; + private static final long serialVersionUID = 406993878174183557L; + private String vfcName; + private String vfcInvariantResourceUUID; private List<CldsAlarmCondition> cldsAlarmConditions; public String getVfcName() { diff --git a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java index e10971e7..e144a0eb 100644 --- a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java +++ b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -23,24 +23,25 @@ package org.onap.clamp.clds.model; -import org.jboss.resteasy.spi.BadRequestException; - import java.util.List; +import org.jboss.resteasy.spi.BadRequestException; + /** * Represent a DCAE Event. */ public class DcaeEvent { - public static final String EVENT_CREATED = "created"; // this is an event we (clds) sends to dcae - public static final String EVENT_DISTRIBUTION = "distribution"; - public static final String EVENT_DEPLOYMENT = "deployment"; - public static final String EVENT_UNDEPLOYMENT = "undeployment"; - public static final String ARTIFACT_NAME_SUFFIX = ".yml"; - - private String event; - private String serviceUUID; - private String resourceUUID; - private String artifactName; // controlName.yml + // this is an event we (clds) sends to dcae + public static final String EVENT_CREATED = "created"; + public static final String EVENT_DISTRIBUTION = "distribute"; + public static final String EVENT_DEPLOYMENT = "deployment"; + public static final String EVENT_UNDEPLOYMENT = "undeployment"; + public static final String ARTIFACT_NAME_SUFFIX = ".yml"; + + private String event; + private String serviceUUID; + private String resourceUUID; + private String artifactName; // controlName.yml private List<CldsModelInstance> instances; /** @@ -51,21 +52,24 @@ public class DcaeEvent { public String getCldsActionCd() { if (event == null || event.length() == 0) { throw new BadRequestException("action null or empty"); - } else if (event.equals(EVENT_CREATED)) { + } else if (event.equalsIgnoreCase(EVENT_CREATED)) { return CldsEvent.ACTION_CREATE; - } else if (event.equals(EVENT_DISTRIBUTION)) { + } else if (event.equalsIgnoreCase(EVENT_DISTRIBUTION)) { return CldsEvent.ACTION_DISTRIBUTE; - } else if (event.equals(EVENT_DEPLOYMENT) && - (instances == null || instances.size() == 0)) { - return CldsEvent.ACTION_UNDEPLOY; - } else if (event.equals(EVENT_DEPLOYMENT)) { + } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT) && (instances == null || instances.size() == 0)) { + return CldsEvent.ACTION_DEPLOY; + } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT)) { return CldsEvent.ACTION_DEPLOY; - // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of - // deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that - // are still deployed with any not on the list considered undeployed. - //} else if ( event.equals(EVENT_UNDEPLOYMENT) ) { - // return CldsEvent.ACTION_UNDEPLOY; + // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy + // individual instances. It will send an empty list of + // deployed instances to indicate all have been removed. Or it will + // send an updated list to indicate those that + // are still deployed with any not on the list considered + // undeployed. + } else if (event.equals(EVENT_UNDEPLOYMENT)) { + return CldsEvent.ACTION_UNDEPLOY; } + throw new BadRequestException("event value not valid: " + event); } @@ -78,7 +82,8 @@ public class DcaeEvent { if (artifactName != null && artifactName.endsWith(ARTIFACT_NAME_SUFFIX)) { return artifactName.substring(0, artifactName.length() - ARTIFACT_NAME_SUFFIX.length()); } else { - throw new BadRequestException("artifactName value not valid (expecting it to end with " + ARTIFACT_NAME_SUFFIX + "): " + artifactName); + throw new BadRequestException("artifactName value not valid (expecting it to end with " + + ARTIFACT_NAME_SUFFIX + "): " + artifactName); } } @@ -90,7 +95,8 @@ public class DcaeEvent { } /** - * @param event the event to set + * @param event + * the event to set */ public void setEvent(String event) { this.event = event; @@ -104,7 +110,8 @@ public class DcaeEvent { } /** - * @param serviceUUID the serviceUUID to set + * @param serviceUUID + * the serviceUUID to set */ public void setServiceUUID(String serviceUUID) { this.serviceUUID = serviceUUID; @@ -118,7 +125,8 @@ public class DcaeEvent { } /** - * @param resourceUUID the resourceUUID to set + * @param resourceUUID + * the resourceUUID to set */ public void setResourceUUID(String resourceUUID) { this.resourceUUID = resourceUUID; @@ -132,7 +140,8 @@ public class DcaeEvent { } /** - * @param artifactName the artifactName to set + * @param artifactName + * the artifactName to set */ public void setArtifactName(String artifactName) { this.artifactName = artifactName; diff --git a/src/main/java/org/onap/clamp/clds/model/ValueItem.java b/src/main/java/org/onap/clamp/clds/model/ValueItem.java index 804d1854..a3a81425 100644 --- a/src/main/java/org/onap/clamp/clds/model/ValueItem.java +++ b/src/main/java/org/onap/clamp/clds/model/ValueItem.java @@ -49,7 +49,8 @@ public class ValueItem { } /** - * @param value the value to set + * @param value + * the value to set */ public void setValue(String value) { this.value = value; |