Modify the intent report model and create a table 62/134562/1
authorkaixiliu <liukaixi@chinamobile.com>
Tue, 16 May 2023 02:21:45 +0000 (10:21 +0800)
committerkaixiliu <liukaixi@chinamobile.com>
Tue, 16 May 2023 02:27:08 +0000 (10:27 +0800)
Issue-ID: USECASEUI-812
Signed-off-by: kaixiliu <liukaixi@chinamobile.com>
Change-Id: I33221660b76dd54306fb447d29d60fc5faeb0617

intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/FulfillmentInfo.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/FulfillmentOperation.java [new file with mode: 0644]
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentReport.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentReportFulfillmentInfo.java [new file with mode: 0644]
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentReportController.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ComponentNotificationService.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ComponentNotificationServiceImpl.java
intentanalysis/src/main/resources/intent-analysis-init.sql

index dbd908e..ea899b2 100644 (file)
@@ -20,6 +20,8 @@ import lombok.Data;
 import org.onap.usecaseui.intentanalysis.bean.enums.FulfillmentStatus;
 import org.onap.usecaseui.intentanalysis.bean.enums.NotFulfilledState;
 
+import java.util.List;
+
 @Data
 
 public class FulfillmentInfo {
@@ -33,4 +35,5 @@ public class FulfillmentInfo {
 
     private String achieveValue;
 
+    private List<String> objectInstances;
 }
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/FulfillmentOperation.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/FulfillmentOperation.java
new file mode 100644 (file)
index 0000000..58a5623
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2023 CMCC, Inc. and others. 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.
+ * 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
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.bean.models;
+
+import lombok.Data;
+
+@Data
+public class FulfillmentOperation extends FulfillmentInfo {
+    //Assurance or modifyBW
+    private String operation;
+}
index 5dfc7a8..69ad2f4 100644 (file)
@@ -25,6 +25,5 @@ public class IntentReport {
     private String intentReportId;
     private String intentReference;
     private List<FulfillmentInfo> fulfillmentInfos;
-    private List<String> objectInstance;
-    private Date reportTime;
+    private String reportTime;
 }
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentReportFulfillmentInfo.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentReportFulfillmentInfo.java
new file mode 100644 (file)
index 0000000..ee3bd4e
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2023 CMCC, Inc. and others. 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.
+ * 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
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.bean.models;
+
+import lombok.Data;
+
+@Data
+public class IntentReportFulfillmentInfo extends FulfillmentInfo{
+    // This id is the intentReportId of the associated intentReport
+    private String intentReportId;
+}
index a4dbb45..c9e82a6 100644 (file)
@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.ArrayList;
@@ -47,18 +48,20 @@ public class IntentReportController {
         IntentReport report = new IntentReport();
         report.setIntentReportId("12345");
         report.setIntentReference("intentReort");
-        report.setObjectInstance(Arrays.asList("instance1", "instance2", "instance3"));
         //report.setFulfillmentInfos();
-        LocalDateTime now = LocalDateTime.now();
-        report.setReportTime(Date.from( now.atZone( ZoneId.systemDefault()).toInstant()));
+        Date date = new Date();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
+        report.setReportTime(dateFormat.format(date));
         FulfillmentInfo fu1= new FulfillmentInfo();
         fu1.setFulfillmentId("fulfillmentInfo1");
         fu1.setFulfillmentStatus(FulfillmentStatus.FULFILLED);
+        fu1.setObjectInstances(Arrays.asList("instance1", "instance2", "instance3"));
         FulfillmentInfo fu2= new FulfillmentInfo();
         fu2.setFulfillmentId("fulfillmentInfo2");
         fu2.setFulfillmentStatus(FulfillmentStatus.NOT_FULFILLED);
         fu2.setNotFulfilledState(NotFulfilledState.DEGRADED);
         fu2.setNotFulfilledReason("not fulfilled Reason");
+        fu2.setObjectInstances(Arrays.asList("instance1", "instance2"));
         List<FulfillmentInfo> list = new ArrayList<>();
         list.add(fu1);
         list.add(fu2);
index 29d7ab9..e10618f 100644 (file)
@@ -15,8 +15,8 @@
  */
 package org.onap.usecaseui.intentanalysis.service;
 
-import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationEventModel;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentOperation;
 
 public interface ComponentNotificationService {
-    void callBack(NotificationEventModel eventModel);
+    void callBack(FulfillmentOperation eventModel);
 }
index ea492e1..59c4f45 100644 (file)
 package org.onap.usecaseui.intentanalysis.service.impl;
 
 import lombok.extern.slf4j.Slf4j;
-import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationEventModel;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentOperation;
 import org.onap.usecaseui.intentanalysis.service.ComponentNotificationService;
 import org.springframework.stereotype.Service;
+
 @Slf4j
 @Service
-public class ComponentNotificationServiceImpl  implements ComponentNotificationService {
+public class ComponentNotificationServiceImpl implements ComponentNotificationService {
+
     /**
-     * transform NoticationEventModel to fulfillment
+     * Generate a new FulfillmentInfo based on third-party FulfillmentOperation
+     * and save it in the database
+     *
      * @param eventModel
      */
     @Override
-    public void callBack(NotificationEventModel eventModel) {
+    public void callBack(FulfillmentOperation eventModel) {
         log.info("callBack begin");
     }
 }
index ee7f8af..61ea45b 100644 (file)
@@ -43,7 +43,8 @@ create table if not exists fulfillment_info(
     fulfillment_info_id varchar(255) primary key,
     fulfillment_info_status varchar(255),
     not_fulfilled_state varchar(255),
-    not_fulfilled_reason varchar(255)
+    not_fulfilled_reason varchar(255),
+    achieve_value varchar(255)
 );
 
 create table if not exists state(
@@ -80,3 +81,23 @@ create table if not exists intent_event_record(
     operate_type varchar (225),
     parent_id varchar(255)
     );
+
+create table if not exists intent_report(
+    intent_report_id varchar(255) primary key,
+    intent_reference varchar(255),
+    report_time timestamptz
+    );
+
+create table if not exists intent_report_fulfillment_info(
+    parent_id varchar(255),
+    fulfillment_info_id varchar(255),
+    fulfillment_info_status varchar(255),
+    not_fulfilled_state varchar(255),
+    not_fulfilled_reason varchar(255),
+    achieve_value varchar(255)
+    );
+
+create table if not exists object_instance(
+    parent_id varchar(255),
+    object_instance varchar(255)
+    );