2 * ============LICENSE_START==============================================
3 * Copyright (c) 2019 AT&T Intellectual Property.
4 * =======================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain a
7 * copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 * ============LICENSE_END=================================================
20 package org.onap.optf.cmso.optimizer.clients.ticketmgt;
22 import java.util.Optional;
23 import java.util.UUID;
24 import org.onap.observations.Observation;
25 import org.onap.optf.cmso.optimizer.clients.ticketmgt.models.ActiveTicketsResponse;
26 import org.onap.optf.cmso.optimizer.common.LogMessages;
27 import org.onap.optf.cmso.optimizer.model.Request;
28 import org.onap.optf.cmso.optimizer.model.Ticket;
29 import org.onap.optf.cmso.optimizer.model.Topology;
30 import org.onap.optf.cmso.optimizer.model.dao.RequestDao;
31 import org.onap.optf.cmso.optimizer.model.dao.TicketDao;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.core.env.Environment;
34 import org.springframework.stereotype.Component;
37 * Ticket Mgt request manager.
43 public class TicketMgtRequestManager {
49 RequestDao requestDao;
55 TicketMgtClient ticketmgtClient;
58 * Creates the tickets request.
60 * @param requestRow the uuid
61 * @return the active tickets response
63 public ActiveTicketsResponse createTicketsRequest(Request requestRow) {
65 Optional<Ticket> rowOpt = ticketDao.findById(requestRow.getUuid());
66 if (rowOpt.isPresent()) {
72 row.setUuid(requestRow.getUuid());
73 row.setTicketsRetries(0);
75 ActiveTicketsResponse apiResponse = ticketmgtClient.makeRequest(requestRow, row);
80 * Gets the existing tickets.
82 * @param uuid the uuid
83 * @return the existing tickets
85 public Ticket getExistingTickets(UUID uuid) {
86 Optional<Ticket> opt = ticketDao.findById(uuid);
87 if (opt.isPresent()) {