aboutsummaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentReportController.java
blob: 4d7369fbe13a69ca328fc32b21c4bae06a438b9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * 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.controller;

import lombok.extern.log4j.Log4j2;
import org.onap.usecaseui.intentanalysis.bean.enums.FulfilmentStatus;
import org.onap.usecaseui.intentanalysis.bean.enums.NotFulfilledState;
import org.onap.usecaseui.intentanalysis.bean.models.*;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import static org.onap.usecaseui.intentanalysis.common.ResponseConsts.RSEPONSE_SUCCESS;

@Log4j2
@RestController
@RequestMapping("/intentReport")
public class IntentReportController {

    @GetMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE)
    public ServiceResult getIntentById(
            @PathVariable("intentId") String intentId) {
        // test connection with ui,real log
        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()));
        FulfilmentInfo fu1= new FulfilmentInfo();
        fu1.setFulfillmentId("fulfilmentInfo1");
        fu1.setFulfillmentStatus(FulfilmentStatus.FULFILLED);
        FulfilmentInfo fu2= new FulfilmentInfo();
        fu2.setFulfillmentId("fulfilmentInfo2");
        fu2.setFulfillmentStatus(FulfilmentStatus.NOT_FULFILLED);
        fu2.setNotFulfilledState(NotFulfilledState.DEGRADED);
        fu2.setNotFulfilledReason("not fulfilled Reason");
        List<FulfilmentInfo> list = new ArrayList<>();
        list.add(fu1);
        list.add(fu2);
        report.setFulfillmentInfos(list);

        return new ServiceResult(new ResultHeader(RSEPONSE_SUCCESS, "get report success"),
                report);

    }

}