c9e82a68a629071d376d5f70c1f8e1aa338fbe93
[usecase-ui/intent-analysis.git] /
1 /*
2  * Copyright (C) 2023 CMCC, Inc. and others. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.usecaseui.intentanalysis.controller;
17
18 import lombok.extern.log4j.Log4j2;
19 import org.onap.usecaseui.intentanalysis.bean.enums.FulfillmentStatus;
20 import org.onap.usecaseui.intentanalysis.bean.enums.NotFulfilledState;
21 import org.onap.usecaseui.intentanalysis.bean.models.*;
22 import org.springframework.http.MediaType;
23 import org.springframework.http.ResponseEntity;
24 import org.springframework.web.bind.annotation.GetMapping;
25 import org.springframework.web.bind.annotation.PathVariable;
26 import org.springframework.web.bind.annotation.RequestMapping;
27 import org.springframework.web.bind.annotation.RestController;
28
29 import java.text.SimpleDateFormat;
30 import java.time.LocalDateTime;
31 import java.time.ZoneId;
32 import java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.Date;
35 import java.util.List;
36
37 import static org.onap.usecaseui.intentanalysis.common.ResponseConsts.RSEPONSE_SUCCESS;
38
39 @Log4j2
40 @RestController
41 @RequestMapping("/intentReport")
42 public class IntentReportController {
43
44     @GetMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE)
45     public ServiceResult getIntentById(
46             @PathVariable("intentId") String intentId) {
47         // test connection with ui,real log
48         IntentReport report = new IntentReport();
49         report.setIntentReportId("12345");
50         report.setIntentReference("intentReort");
51         //report.setFulfillmentInfos();
52         Date date = new Date();
53         SimpleDateFormat dateFormat = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
54         report.setReportTime(dateFormat.format(date));
55         FulfillmentInfo fu1= new FulfillmentInfo();
56         fu1.setFulfillmentId("fulfillmentInfo1");
57         fu1.setFulfillmentStatus(FulfillmentStatus.FULFILLED);
58         fu1.setObjectInstances(Arrays.asList("instance1", "instance2", "instance3"));
59         FulfillmentInfo fu2= new FulfillmentInfo();
60         fu2.setFulfillmentId("fulfillmentInfo2");
61         fu2.setFulfillmentStatus(FulfillmentStatus.NOT_FULFILLED);
62         fu2.setNotFulfilledState(NotFulfilledState.DEGRADED);
63         fu2.setNotFulfilledReason("not fulfilled Reason");
64         fu2.setObjectInstances(Arrays.asList("instance1", "instance2"));
65         List<FulfillmentInfo> list = new ArrayList<>();
66         list.add(fu1);
67         list.add(fu2);
68         report.setFulfillmentInfos(list);
69
70         return new ServiceResult(new ResultHeader(RSEPONSE_SUCCESS, "get report success"),
71                 report);
72
73     }
74
75 }